2013年4月27日 星期六

10:33

1redo (重做) log 的功能:        用于数据恢复  

2redo log 特征:

【特征】:

1)   记录数据块的变化(DML、DDL)

2)   用于数据块的recover

3)   以组的方式管理redo file ,最少两组redo ,循环使用

4)   和数据文件存放到不同的磁盘上,需读写速度快的磁盘(比如采用RAID10)

5)   online   redolog    在线日志

        

日志组 和 日志文件的状态  

日志组的status:

unused   新添加的日志组,还没有使用

inactive  日志组对应的脏块已经从data buffer写入到data file ,可以删除

active     日志组对应的脏块还没有从data buffer写入到data file,不能被删除,否则会引起数据丢失

current   当前日志组,日志组对应的脏块还没有从data buffer写入到data file,不能被删除

在删除日志组之前,进行日志手工切换,将被删除的日志切换到inactive状态,这样就不会引起数据丢失

thread :线程(通过后台进程lgwr 启动),在单实例的环境下,thread# 永远是1

sequence :日志序列号。在日志切换时会递增。

FIRST_CHANGE# :在当前日志中记录的首个数据块的scn。(当事务完成的时候会在数据块上写入一个scn,代表数据块的变化)。

ARC:是否归档模式

log_checkpoints_to_alter  该值默认为false,将其设置为true,每生成一个检查点就会在alter告警日志记录信息

日志文件的status

valid     有效状态

invalid   当数据库未使用该组文件时,就是无效状态

stale     当数据库怀疑日志文件没完成或者不正确时,日志文件为不新鲜状态,当该日志组变为active group 时,stale日志文件会变为valid状态

 

日志切换:

1) 归档模式:将历史日志进行保存 ,并产生checkpoint,通知redo log 把对应的 dirty block 从data buffer写入到datafile,并且更新控制文件

2)非归档: 历史日志被覆盖archive log list 可以查看数据库是否启用归档模式】

与日志相关的的数据字典

V$LOG  查看日志信息(从控制文件读取)

V$LOGFILE 查看日志存放的位置

FAST_START_MTTR_TARGET      控制检查点出现的时间也就是 实例恢复所需要的最长的时间  不能设置的太短

ALTER  SYSTEM  SWITH  LOGFILE;   产生增量检查点

ALTER  SYSTEM  CHECKPONIT;          手工生成检查点 即:   产生完全检查点,促使 所有的脏块都写入数据文件

3redo 日志组

1)  最少两组,最好每组有两个成员,并存放到不同的磁盘上,大小相同,互相镜像

2)  日志在写满时发生切换,或

手工切换:alter system switch logfile ;

3)  在归档模式,日志进行归档,并把相关的信息写入controlfile

4、添加日志组

SQL> startup

ORACLE instance started.

Total System Global Area  251658240 bytes

Fixed Size                  1218820 bytes

Variable Size             134219516 bytes

Database Buffers          113246208 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM

---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

2          1          7   10485760          1 NO  CURRENT                 381102 02-AUG-11

1          1          6   10485760          1 NO  INACTIVE                357157 01-AUG-11

SQL> select group#, member from v$logfile;

GROUP# MEMBER

---------- --------------------------------------------------

2 /u01/app/oracle/oradata/cuug/redo02a.log

1 /u01/app/oracle/oradata/cuug/redo01a.log

添加 日志组

SQL> alter database   add   logfile       group     4   

'/u01/app/oracle/oradata/cuug/redo03a.log' size 10m;                  ——添加日志组

Database altered.

添加日志 成员

SQL> alter database add logfile member

'/disk1/cuug/oradata/redo01b.log' to group 1,            指定哪个日志组

'/disk1/cuug/oradata/redo02b.log' to group 2,

'/disk1/cuug/oradata/redo03b.log' to group 3 ;  ——添加日志组成员,放在不同的磁盘,形成镜像

Database altered.

SQL> select group#, member from  v$logfile  ;

GROUP# MEMBER

---------- --------------------------------------------------

2 /u01/app/oracle/oradata/cuug/redo02a.log

1 /u01/app/oracle/oradata/cuug/redo01a.log

3 /u01/app/oracle/oradata/cuug/redo03a.log

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC    STATUS           FIRST_CHANGE#      FIRST_TIM

---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

1                 1                 6                 10485760          1        NO      INACTIVE                357157                 01-AUG-11

3                 1                 0                 10485760          1      YES      UNUSED                                                   0      ——刚创建的日志组,处于未使用状态,进行日志切换即可

2                 1                 7                 10485760          1        NO      CURRENT                 381102                02-AUG-11

SQL> alter system switch logfile;                      手工切换日志 

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARCHIVED  STATUS     FIRST_CHANGE# FIRST_TIME

---------- ---------- ---------- ---------- ---------- --------- ---------- ------------- -------------------

1          1          7  104857600          1 NO        INACTIVE          215301 2012-03-07 18:02:39

4          1         10  104857600          1 NO        CURRENT           238364 2012-03-08 17:14:10

3          1          9  104857600          1 NO        ACTIVE            237357 2012-03-08 16:49:45

2          1          8  104857600          1 NO        INACTIVE          216223 2012-03-07 18:49:17

5、添加日志组的成员

为什么多元化日志成员 ???

【如果当前日志组只有一个成员并且日志成员所在磁盘损坏, oracle  无法写入日志就会发生实例  crash  (实例崩溃)

所以建议大家多元化日志成员】

SQL> select group#, member from v$logfile;

GROUP# MEMBER

---------- --------------------------------------------------

2 /u01/app/oracle/oradata/cuug/redo02a.log

1 /u01/app/oracle/oradata/cuug/redo01a.log

3 /u01/app/oracle/oradata/cuug/redo03a.log

SQL>  select group#, member from v$logfile order by 1;

GROUP# MEMBER

---------- --------------------------------------------------

1 /u01/app/oracle/oradata/cuug/redo01a.log

1 /disk1/cuug/oradata/redo01b.log

2 /disk1/cuug/oradata/redo02b.log

2 /u01/app/oracle/oradata/cuug/redo02a.log

3 /disk1/cuug/oradata/redo03b.log

3 /u01/app/oracle/oradata/cuug/redo03a.log

6、查看日志信息

SYS@ prod>select SEQUENCE# ,FIRST_CHANGE#,NEXT_CHANGE# ,to_char(FIRST_TIME  ,'yyyy-mm-dd- hh24:mi:ss')  from v$log_history;

SEQUENCE# FIRST_CHANGE# NEXT_CHANGE# TO_CHAR(FIRST_TIME,'

---------- ------------- ------------ --------------------

1        446075       474850 2013-01-09- 03:55:23

2        474850       496815 2013-01-09- 03:59:39

3        496815       497931 2013-01-09- 04:02:31

4        497931       497947 2013-01-09- 04:38:17

5        497947       497961 2013-01-09- 04:39:01

6        497961       497971 2013-01-09- 04:39:36

7        497971       497975 2013-01-09- 04:39:58

8        497975       497983 2013-01-09- 04:40:03

9        497983       497986 2013-01-09- 04:40:21

10        497986       498899 2013-01-09- 04:40:25

11        498899       499047 2013-01-09- 05:01:09

12        499047       499055 2013-01-09- 05:02:54

13        499055       531192 2013-01-09- 05:02:58

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM

---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

1          1          6   10485760          2 NO  INACTIVE                357157 01-AUG-11

3          1          0   10485760          2 YES UNUSED                       0

2          1          7   10485760          2 NO  CURRENT                 381102 02-AUG-11

SQL> alter system switch logfile;

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS    ARC    STATUS           FIRST_CHANGE# FIRST_TIM

---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

1                1                    9              10485760          2              NO     CURRENT             384007 02-AUG-11

3                1                    8              10485760          2              NO     ACTIVE                  384005 02-AUG-11

2                1                    7              10485760          2              NO     ACTIVE                  381102 02-AUG-11

通过查询日志切换时间  可知道 系统哪个时间段 事务繁忙

  SYS@ prod>desc  v$log_history;

Name                                                              Null?    Type

----------------------------------------------------------------- -------- --------------------------------------------

RECID                                                                                             NUMBER

STAMP                                                                                            NUMBER

THREAD#                                                                                         NUMBER

SEQUENCE#                                                                                  NUMBER

FIRST_CHANGE#                                                                          NUMBER

FIRST_TIME                                                                                  DATE

NEXT_CHANGE#                                                                          NUMBER

RESETLOGS_CHANGE#                                                               NUMBER

RESETLOGS_TIME                                                                       DATE

SYS@ prod>select SEQUENCE# ,FIRST_CHANGE#,NEXT_CHANGE# ,to_char(FIRST_TIME  ,'yyyy-mm-dd- hh24:mi:ss')  time from v$log_history;

【Oracle建议 切换时间为 15分钟】

SEQUENCE#       FIRST_CHANGE#      NEXT_CHANGE#     TIME

---------- ------------- ------------ --------------------

1                        446075                  474850                    2013-01-09- 03:55:23

2                       474850                   496815                    2013-01-09- 03:59:39

3                       496815                   497931                    2013-01-09- 04:02:31

4                       497931                   497947                    2013-01-09- 04:38:17

5                       497947                   497961                    2013-01-09- 04:39:01

6                       497961                   497971                    2013-01-09- 04:39:36

7                       497971                   497975                    2013-01-09- 04:39:58

8                      497975                    497983                    2013-01-09- 04:40:03

9                      497983                    497986                    2013-01-09- 04:40:21

10                     497986                    498899                    2013-01-09- 04:40:25

11                     498899                    499047                    2013-01-09- 05:01:09

12                     499047                    499055                    2013-01-09- 05:02:54

13                      499055                    531192                    2013-01-09- 05:02:58

----------查看生成的日志量

SQL> insert into scott.emp1 select * from scott.emp1;

28 rows created.

SQL> insert into scott.emp1 select * from scott.emp1;

56 rows created.


——通过联合查询视图 v$statname ,v$mystat可以查看日志生成量                                                         

SYS @ prod >select a.name, b.value/1024/1024 "SIZE: M" from v$statname a,v$mystat b   where b.statistic#=a.statistic# and a.name like '%redo size%';

NAME                                                                SIZE: M

---------------------------------------------------------------- ----------

redo size                                                        .019523621

 7redo 日志成员重命名或迁移  【只能在mount状态下修改因为mount状态打开了控制文件】一定要确认新的位置有该文件否则报错  总之先改物理位置再改逻辑位置  无法修改日志文件的大小因为日志文件一旦建立就已经被格式化为oracle标准格式  所以无法修改

SQL> select group#,member from v$logfile order by 1;

GROUP# MEMBER

---------- --------------------------------------------------

1 /u01/app/oracle/oradata/cuug/redo01a.log

1 /disk1/cuug/oradata/redo01b.log

2 /disk1/cuug/oradata/redo02b.log

2 /u01/app/oracle/oradata/cuug/redo02a.log

3 /disk1/cuug/oradata/redo03b.log

3 /u01/app/oracle/oradata/cuug/redo03a.log

6 rows selected.

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

[oracle@oracle ~]$ cp /u01/app/oracle/oradata/cuug/redo01a.log /disk2/cuug/oradata/

[oracle@oracle ~]$ cp /u01/app/oracle/oradata/cuug/redo02a.log /disk2/cuug/oradata

[oracle@oracle ~]$ cp /u01/app/oracle/oradata/cuug/redo03a.log /disk2/cuug/oradata

[oracle@oracle ~]$ !sql

sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Aug 2 05:08:35 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup mount  ;

ORACLE instance started.

Total System Global Area  251658240 bytes

Fixed Size                  1218820 bytes

Variable Size             125830908 bytes

Database Buffers          121634816 bytes

Redo Buffers                2973696 bytes

Database mounted.

SQL> select group# ,member from v$logfile order by 1;

GROUP# MEMBER

---------- --------------------------------------------------

1 /u01/app/oracle/oradata/cuug/redo01a.log

1 /disk1/cuug/oradata/redo01b.log

2 /disk1/cuug/oradata/redo02b.log

2 /u01/app/oracle/oradata/cuug/redo02a.log

3 /disk1/cuug/oradata/redo03b.log

3 /u01/app/oracle/oradata/cuug/redo03a.log

SQL> alter database rename file       '/u01/app/oracle/oradata/cuug/redo01a.log'   to   '/disk2/cuug/oradata/redo01a.log';

Database altered.

SQL> alter database rename file      '/u01/app/oracle/oradata/cuug/redo02a.log' to '/disk2/cuug/oradata/redo02a.log';

Database altered.

SQL> alter database rename file    '/u01/app/oracle/oradata/cuug/redo03a.log' to '/disk2/cuug/oradata/redo03a.log';

Database altered.

SQL> select group# ,member from v$logfile order by 1;

GROUP# MEMBER

---------- --------------------------------------------------

1 /disk2/cuug/oradata/redo01a.log

1 /disk1/cuug/oradata/redo01b.log

2 /disk1/cuug/oradata/redo02b.log

2 /disk2/cuug/oradata/redo02a.log

3 /disk1/cuug/oradata/redo03b.log

3 /disk2/cuug/oradata/redo03a.log

6 rows selected.

SQL> alter database open;

Database altered.

SQL> select group# ,member from v$logfile order by 1;

GROUP# MEMBER

---------- --------------------------------------------------

1 /disk2/cuug/oradata/redo01a.log

1 /disk1/cuug/oradata/redo01b.log

2 /disk1/cuug/oradata/redo02b.log

2 /disk2/cuug/oradata/redo02a.log

3 /disk1/cuug/oradata/redo03b.log

3 /disk2/cuug/oradata/redo03a.log

6 rows selected.

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM

---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

1          1          9   10485760          2 NO  INACTIVE                384007 02-AUG-11

3          1          8   10485760          2 NO  INACTIVE                384005 02-AUG-11

2          1         10   10485760          2 NO  CURRENT                 385481 02-AUG-11

日志文件 clear 

假如主机断电  数据库启动报错该日志组的日志文件损坏必须要保证该日志组的状态不是current

Alter  database  clear   logfile    group  1;            清空损坏的日志组  就可以打开数据库了打开数据库以后oracle自行创建该组的日志成员

Alter  database clear   unarchived   logfile  group 2  ;     此乃当前日志组  报错      该日志组需要归档

8、日志恢复

   

1、多元化成员中,单个组成员丢失(不会影响到数据库的正常运行)(当前组和非当前组的都一样)

解决方法:复制一下就行

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM

---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

1          1          9   10485760          2 NO  INACTIVE                384007 02-AUG-11

3          1          8   10485760          2 NO  INACTIVE                384005 02-AUG-11

2          1         10   10485760         2 NO  CURRENT                 385481 02-AUG-11

[oracle@oracle ~]$ ls /disk2/lx01/oradata/

control03.ctl  redo01a.log  redo02a.log  redo03a.log  redo04a.log  redo05a.log

[oracle@oracle ~]$ exit

exit

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

05:14:41 SQL> !

[oracle@oracle ~]$ rm  /disk2/cuug/oradata/redo01a.log

[oracle@oracle ~]$ !sql

sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Aug 2 05:15:02 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area  251658240 bytes

Fixed Size                  1218820 bytes

Variable Size             125830908 bytes

Database Buffers          121634816 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM

---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

1          1          9   10485760          2 NO  INACTIVE                384007 02-AUG-11

3          1          8   10485760          2 NO  INACTIVE                384005 02-AUG-11

2          1         10   10485760          2 NO  CURRENT                 385481 02-AUG-11

SQL> desc v$logfile;

Name                                                                                Null?    Type

----------------------------------------------------------------------------------- --------

GROUP#                                                                                       NUMBER

STATUS                                                                                       VARCHAR2(7)

TYPE                                                                                         VARCHAR2(7)

MEMBER                                                                                       VARCHAR2(513)

IS_RECOVERY_DEST_FILE                                                                        VARCHAR2(3)

SQL>select group#,member ,status from v$logfile

GROUP# MEMBER                                             STATUS

---------- -------------------------------------------------- -------

2 /disk2/cuug/oradata/redo02a.log

1 /disk2/cuug/oradata/redo01a.log                    INVALID

3 /disk2/cuug/oradata/redo03a.log

1 /disk1/cuug/oradata/redo01b.log

2 /disk1/cuug/oradata/redo02b.log

3 /disk1/cuug/oradata/redo03b.log

告警日志:

Errors in file /u01/app/oracle/admin/cuug/bdump/cuug_lgwr_9105.trc:

ORA-00313: open failed for members of log group 1 of thread 1

ORA-00312: online log 1 thread 1: '/disk2/cuug/oradata/redo01a.log'

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

解决:

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> !

[oracle@oracle ~]$ cp /disk1/cuug/oradata/redo01b.log /disk2/cuug/oradata/redo01a.log

[oracle@oracle ~]$ !sql

sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Aug 2 05:18:02 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area  251658240 bytes

Fixed Size                  1218820 bytes

Variable Size             125830908 bytes

Database Buffers          121634816 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

SQL> select group#,member ,status from v$logfile ;

GROUP# MEMBER                                             STATUS

---------- -------------------------------------------------- -------

2 /disk2/cuug/oradata/redo02a.log

1 /disk2/cuug/oradata/redo01a.log                    INVALID

3 /disk2/cuug/oradata/redo03a.log

1 /disk1/cuug/oradata/redo01b.log

2 /disk1/cuug/oradata/redo02b.log

3 /disk1/cuug/oradata/redo03b.log

SQL> alter system switch logfile;

System altered.

SQL> select group#,member ,status from v$logfile  ;

GROUP# MEMBER                                             STATUS

---------- -------------------------------------------------- -------

2 /disk2/cuug/oradata/redo02a.log

1 /disk2/cuug/oradata/redo01a.log

3 /disk2/cuug/oradata/redo03a.log

1 /disk1/cuug/oradata/redo01b.log

2 /disk1/cuug/oradata/redo02b.log

3 /disk1/cuug/oradata/redo03b.log

    、非当前日志组所有成员丢失(数据库打不开,只丢失单个就没影响,全丢失了就无法正常打开数据库)

    解决方法:alter database clear logfile group 2  清理该组的所有成员日志即可

(清理一下该日志组的文件信息,因为日志组的状态是inactive,所有的脏块已经写入数据库,这样在启动时就不会进行校验了,此时数据库可以正常启动,当使用到该日志组的时候会自动创建日志组成员)

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM

---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

1          1         12   10485760          2 NO  CURRENT                 386507 02-AUG-11

3          1         11   10485760          2 NO  INACTIVE                386505 02-AUG-11

2          1         10   10485760          2 NO  INACTIVE                385481 02-AUG-11

SQL> shutdown

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

SQL> !

[oracle@oracle ~]$ rm /disk2/cuug/oradata/redo02a.log

[oracle@oracle ~]$ rm /disk1/cuug/oradata/redo02b.log

[oracle@oracle ~]$ !sql

sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Aug 2 05:20:21 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area  251658240 bytes

Fixed Size                  1218820 bytes

Variable Size             125830908 bytes

Database Buffers          121634816 bytes

Redo Buffers                2973696 bytes

Database mounted.

ORA-00313: open failed for members of log group 2 of thread 1

ORA-00312: online log 2 thread 1: '/disk2/cuug/oradata/redo02a.log'

ORA-00312: online log 2 thread 1: '/disk1/cuug/oradata/redo02b.log'

SQL> alter database clear logfile group 2;    清理该组所有的日志文件,当使用该日志组文件时会自动创建日志组成员

Database altered.

SQL> alter database open;

Database altered.

       

3、当前日志组丢失(正常关库 shutdown immediate)

解决方法:   

recover database until cancel;(使用当前日志文件进行恢复,在这里没有实际作用)

alter database open resetlogs;(对日志进行重设,日志的序列号和周期都发生变化)

(只要数据库正常关库,脏块都已经写入到数据库中,对日志重设不会影响数据文件)

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM

---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

1          1         12   10485760          2 NO  INACTIVE                386507 02-AUG-11

3          1         14   10485760          2 NO  CURRENT                 386751 02-AUG-11

2          1         13   10485760          2 NO  ACTIVE                  386654 02-AUG-11

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

[oracle@oracle ~]$ rm /disk2/cuug/oradata/redo03a.log

[oracle@oracle ~]$ rm /disk1/cuug/oradata/redo03b.log

[oracle@oracle ~]$ !sql

sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Aug 2 05:23:03 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area  251658240 bytes

Fixed Size                  1218820 bytes

Variable Size             125830908 bytes

Database Buffers          121634816 bytes

Redo Buffers                2973696 bytes

Database mounted.

ORA-00313: open failed for members of log group 3 of thread 1

ORA-00312: online log 3 thread 1: '/disk2/cuug/oradata/redo03a.log'

ORA-00312: online log 3 thread 1: '/disk1/cuug/oradata/redo03b.log'

告警日志:

Errors in file /u01/app/oracle/admin/cuug/bdump/cuug_lgwr_9314.trc:

ORA-00313: open failed for members of log group 3 of thread 1

ORA-00312: online log 3 thread 1: '/disk1/cuug/oradata/redo03b.log'

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

ORA-00312: online log 3 thread 1: '/disk2/cuug/oradata/redo03a.log'

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

Tue Aug  2 05:23:10 2011

Errors in file /u01/app/oracle/admin/cuug/bdump/cuug_lgwr_9314.trc:

ORA-00313: open failed for members of log group 3 of thread 1

ORA-00312: online log 3 thread 1: '/disk1/cuug/oradata/redo03b.log'

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

ORA-00312: online log 3 thread 1: '/disk2/cuug/oradata/redo03a.log'

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

ORA-313 signalled during: ALTER DATABASE OPEN...

解决:

SQL> alter database clear logfile group 3;(既不能drop也不能clear,这是数据库的保护机制,认为日志对应的脏块未写入数据文件)

alter database clear logfile group 3

*

ERROR at line 1:

ORA-00313: open failed for members of log group 3 of thread 1

ORA-00312: online log 3 thread 1: '/disk1/cuug/oradata/redo03b.log'

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

ORA-00312: online log 3 thread 1: '/disk2/cuug/oradata/redo03a.log'

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

--------对于当前日志组不能clear

 

SQL> recover database until cancel;(使用当前日志文件进行恢复,在这里没有实际作用)

Media recovery complete.

SQL> alter database open;

alter database open

*

ERROR at line 1:

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open(如果用NORESETLOGS会怎么样?)

SQL> alter database open resetlogs;    (对日志进行重设,日志的序列号和周期都发生变化)

(只要数据库正常关库,脏块都已经写入到数据库中,对日志重设不会影响数据文件)

Database altered.

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM

---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

1          1          2   10485760          2 NO  CURRENT                 386892 02-AUG-11

3          1          1   10485760          2 NO  INACTIVE                386891 02-AUG-11

2          1          0   10485760          2 YES UNUSED                       0

SQL> alter system switch logfile;

System altered.

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM

---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

1          1          2   10485760          2 NO  ACTIVE                  386892 02-AUG-11

3          1          1   10485760          2 NO  INACTIVE                386891 02-AUG-11

2          1          3   10485760          2 NO  CURRENT                 387003 02-AUG-11

非正常关库,当前日志组文件丢失(需要修改PFILE,添加隐含参数)

【危险动作,请勿在工作环境下操作】

修改pfile文件,添加_allow_resetlogs_corruption=TRUE

(跳过resetlogs一致性检查,强制起库,会导致出现数据一致性的错误)

[oracle@work dbs]$ vi inittest.ora

_allow_resetlogs_corruption=TRUE

*.background_dump_dest='$ORACLE_BASE/admin/test/bdump'

*.control_files='/u01/app/oracle/oradata/test/control01.ctl','/disk1/oradata/test/control02.ctl','/disk2/oradata/test/control03.ctl'

*.core_dump_dest='$ORACLE_BASE/admin/test/cdump'

*.db_block_size=8192

*.db_cache_size=80M#DEMO

*.db_file_multiblock_read_count=16

*.db_name='test'

*.optimizer_mode='choose'

*.parallel_threads_per_cpu=4#SMALL

*.pga_aggregate_target=10485760

*.query_rewrite_enabled='true'

*.query_rewrite_integrity='trusted'

*.shared_pool_size=60M#DEMO

*.star_transformation_enabled='true'

*.undo_management='auto'

*.undo_tablespace='rtbs'

*.user_dump_dest='$ORACLE_BASE/admin/test/udump'

---------再以pfile 启动instance 到mount

然后 alter database open resetlogs (改不好就会出现系统错误)

drop

clear

Oracle11g温习-第七章:redo日志的更多相关文章

  1. Oracle11g温习-第六章:控制文件

    2013年4月27日 星期六 10:33  .控制文件的功能和特点 1) [定义数据库当前物理状态] 2) [维护数据的一致性]  如果控制文件中的检查点与数据文件中的一致,则说明数据一致,可以启动到 ...

  2. Oracle11g温习-第四章:手工建库

     1.create database plan 1.库类型:   OLTP :  在线事务处理系统   OLAP : 在线应用处理系统   DSS :    数据决策系统 2.数据库名字及字符集 3. ...

  3. Oracle11g温习-第八章:归档日志

    2013年4月27日 星期六 10:36 1.归档和非归档的区别 1)  归档会在日志切换时,备份历史日志,用于OLTP(在线事务处理系统),可以进行冷备份和热备份,可以实现数据库完全恢复.不完全恢复 ...

  4. Oracle11g温习-第三章:instance实例管理

    2013年4月27日 星期六 10:30 1.instance 功能:   用于管理和访问database. 2.init parameter files :管理实例相关启动参数.位置:$ORACLE ...

  5. Oracle11g温习-第十三章:索引

    2013年4月27日 星期六 10:46 1.索引(Index)的功能:对记录进行排序,加快表的查询速度  2.索引的分类  1)B-tree 索引(默认) a.在一个大表上 b.建立在重复值比较少的 ...

  6. Oracle11g温习-第五章:数据字典

    1.数据字典(Data dictionary)的功能 1)   central of oracle   database               每个oracle数据库的核心 2)   descr ...

  7. Oracle11g温习-第十七章:权限管理

    2013年4月27日 星期六 10:50 1.权限(privilege):     [system privilege(系统权限):针对于database 的相关权限         object p ...

  8. Oracle11g温习-第十一章:管理undo

    2013年4月27日 星期六 10:40 1.undo tablespace 功能 undo tablespace 功能:用来存放从datafiles 读出的数据块旧的镜像 [             ...

  9. perl5 第七章 控制结构

    第七章 控制结构 by flamephoenix 一.条件判断二.循环:  1.while循环   2.until循环   3.for循环   4.针对列表(数组)每个元素的foreach循环  5. ...

随机推荐

  1. Qt的四个常见的图像叠加模式

    Qt的QPainter::CompositionMode提供了多种图像叠加的模式.常见的有QPainter::CompositionMode_SourceOver, QPainter::Composi ...

  2. Python中模块(Module)和包(Package)的区别

    本文绝大部分内容转载至:廖雪峰官方网站 1. 模块(Module) 在计算机程序的开发过程中,随着程序代码越写越多,在一个文件里代码就会越来越长,越来越不容易维护. 为了编写可维护的代码,我们把很多函 ...

  3. 05: MySQL高级查询

    MySQL其他篇 目录: 参考网站 1.1 GROUP BY分组使用 1.2 mysql中NOW(),CURDATE(),CURTIME()的使用 1.3 DATEDIFF() 函数 1.4 DATE ...

  4. bootstrap3

    bs是基于html5和css3的, h5和css3是今后的趋势. html5只是说文档的 "标准"是h5, 但是文档的类型仍然是 html. 所以在写文档类型的时候, 就不能要那个 ...

  5. Spring的面向切面

    Spring的面向切面 在应用开发中,有很多类似日志.安全和事务管理的功能.这些功能都有一个共同点,那就是很多个对象都需要这些功能.复用这些通用的功能的最简单的方法就是继承或者委托.但是当应用规模达到 ...

  6. 【Android实验】线程的使用-计时器

    目录 实验目的 实验要求 实验过程 实验结果 实验代码 实验总结 实验目的 熟悉和掌握Android线程的使用 实验要求 完成一个秒表,具备启停功能,正确使用工作线程完成界面刷新 分析秒表的计时是否准 ...

  7. async 和 await的前世今生 (转载)

    async 和 await 出现在C# 5.0之后,给并行编程带来了不少的方便,特别是当在MVC中的Action也变成async之后,有点开始什么都是async的味道了.但是这也给我们编程埋下了一些隐 ...

  8. shell 算术运算符

    算术运算符 下表列出了常用的算术运算符,假定变量 a 为 10,变量 b 为 20: 运算符 说明 举例 + 加法 `expr $a + $b` 结果为 30. - 减法 `expr $a - $b` ...

  9. Springboot mybatis generate 自动生成实体类和Mapper

    https://github.com/JasmineQian/SpringDemo_2019/tree/master/mybatis Springboot让java开发变得方便,Springboot中 ...

  10. Qt加载OSg视图例子

    //QT += core gui opengl //LIBS += -losgViewer -losgDB -losgUtil -losg -lOpenThreads -losgGA -losgQt ...