Oracle RMAN 使用RMAN恢复INACTIVE状态的日志

恢复INACTIVE日志组有两种情况
  • 一种是INACTIVE日志组的其中一个成员损坏
  • 一种是INACTIVE日志组所有日志成员都损坏

  • 使用rman恢复INACTIVE日志组的其中一个成员损坏

  • 1、查看当前状态:

sys@TEST1107> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                                             IS_
---------- ------- ------- -------------------------------------------------- ---
         3         ONLINE  /u01/app/oracle/oradata/test1107/redo03.log        NO
         2         ONLINE  /u01/app/oracle/oradata/test1107/redo02.log        NO
         1         ONLINE  /u01/app/oracle/oradata/test1107/redo01.log        NO
         1         ONLINE  /u01/app/oracle/oradata/test1107/redo01a.log       NO
         2         ONLINE  /u01/app/oracle/oradata/test1107/redo02a.log       NO
         3         ONLINE  /u01/app/oracle/oradata/test1107/redo03a.log       NO

6 rows selected.

sys@TEST1107> alter system switch logfile;

System altered.

sys@TEST1107> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIME         NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------------ ------------ ------------------
         1          1          9   52428800        512          2 YES   INACTIVE               1089973 06-NOV-13               1089979 06-NOV-13
         2          1         11   52428800        512          2 NO  CURRENT                1090048 06-NOV-13            2.8147E+14
         3          1         10   52428800        512          2 YES ACTIVE                 1089979 06-NOV-13               1090048 06-NOV-13

  • 2、OS删除一个INACTIVE 状态的日志
[oracle@rtest ~]$ rm /u01/app/oracle/oradata/test1107/redo01.log 


  • 3、模拟断电,然后再启动实例,可以正常打开
sys@TEST1107> shutdown abort
ORACLE instance shut down.
sys@TEST1107> startup
ORACLE instance started.

Total System Global Area 1269366784 bytes
Fixed Size                  2227984 bytes
Variable Size             805306608 bytes
Database Buffers          452984832 bytes
Redo Buffers                8847360 bytes
Database mounted.
Database opened.

  • 4、查看日志组成员状态,发现刚删除那个日志组成员的状态为INVALID 
sys@TEST1107> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                                             IS_
---------- ------- ------- -------------------------------------------------- ---
         3         ONLINE  /u01/app/oracle/oradata/test1107/redo03.log        NO
         2         ONLINE  /u01/app/oracle/oradata/test1107/redo02.log        NO
         1 INVALID ONLINE  /u01/app/oracle/oradata/test1107/redo01.log        NO
         1         ONLINE  /u01/app/oracle/oradata/test1107/redo01a.log       NO
         2         ONLINE  /u01/app/oracle/oradata/test1107/redo02a.log       NO
         3         ONLINE  /u01/app/oracle/oradata/test1107/redo03a.log       NO

6 rows selected.

  • 5、再来查看一下alert日志


Wed Nov 06 10:20:48 2013
Errors in file /u01/app/oracle/diag/rdbms/test1107/test1107/trace/test1107_m000_18904.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/test1107/redo01.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Completed crash recovery at
 Thread 1: logseq 12, block 370, scn 1131445
 140 data blocks read, 140 data blocks written, 183 redo k-bytes read
Errors in file /u01/app/oracle/diag/rdbms/test1107/test1107/trace/test1107_ora_18888.trc:
ORA-00313: open failed for members of log group 1 of thread 1

  • 6、删除再添加损坏的日志组成员

sys@TEST1107> alter database drop logfile member '/u01/app/oracle/oradata/test1107/redo01.log';

Database altered.

sys@TEST1107> alter database add logfile member '/u01/app/oracle/oradata/test1107/redo01.log' to group 1;

Database altered.

  • 7、查看日志成员状态,发现其状态依然是INVALID 
sys@TEST1107> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                                             IS_
---------- ------- ------- -------------------------------------------------- ---
         3         ONLINE  /u01/app/oracle/oradata/test1107/redo03.log        NO
         2         ONLINE  /u01/app/oracle/oradata/test1107/redo02.log        NO
         1 INVALID ONLINE  /u01/app/oracle/oradata/test1107/redo01.log        NO
         1         ONLINE  /u01/app/oracle/oradata/test1107/redo01a.log       NO
         2         ONLINE  /u01/app/oracle/oradata/test1107/redo02a.log       NO
         3         ONLINE  /u01/app/oracle/oradata/test1107/redo03a.log       NO

6 rows selected.

  • 8、切换日志,使其强制使用
sys@TEST1107> alter system switch logfile;

System altered.

sys@TEST1107> alter system switch logfile;


System altered.


sys@TEST1107> alter system switch logfile;

System altered.


  • 9、再来查看日志成员状态,为正常状态
sys@TEST1107> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                                             IS_
---------- ------- ------- -------------------------------------------------- ---
         3         ONLINE  /u01/app/oracle/oradata/test1107/redo03.log        NO
         2         ONLINE  /u01/app/oracle/oradata/test1107/redo02.log        NO
         1         ONLINE  /u01/app/oracle/oradata/test1107/redo01.log        NO
         1         ONLINE  /u01/app/oracle/oradata/test1107/redo01a.log       NO
         2         ONLINE  /u01/app/oracle/oradata/test1107/redo02a.log       NO
         3         ONLINE  /u01/app/oracle/oradata/test1107/redo03a.log       NO

6 rows selected.


  • 使用rman恢复INACTIVE日志组的所有成员损坏


1、首先查看各个日志组的状态


sys@TEST1107> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIME         NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------------ ------------ ------------------
         1          1         18   52428800        512          2 YES INACTIVE               1132950 06-NOV-13               1132957 06-NOV-13
         2          1         20   52428800        512          2 NO  CURRENT                1132964 06-NOV-13            2.8147E+14
         3          1         19   52428800        512          2 YES INACTIVE               1132957 06-NOV-13               1132964 06-NOV-13

sys@TEST1107> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                                             IS_
---------- ------- ------- -------------------------------------------------- ---
         3         ONLINE  /u01/app/oracle/oradata/test1107/redo03.log        NO
         2         ONLINE  /u01/app/oracle/oradata/test1107/redo02.log        NO
         1         ONLINE  /u01/app/oracle/oradata/test1107/redo01.log        NO
         1         ONLINE  /u01/app/oracle/oradata/test1107/redo01a.log       NO
         2         ONLINE  /u01/app/oracle/oradata/test1107/redo02a.log       NO
         3         ONLINE  /u01/app/oracle/oradata/test1107/redo03a.log       NO

6 rows selected.


  • 2、OS删除当前状态为INACTIVE的日志组成员
[oracle@rtest ~]$ rm /u01/app/oracle/oradata/test1107/redo03a.log
[oracle@rtest ~]$ rm /u01/app/oracle/oradata/test1107/redo03.log

  • 3、模拟断电,然后启动实例,报错
sys@TEST1107> shutdown abort
ORACLE instance shut down.
sys@TEST1107> startup
ORACLE instance started.

Total System Global Area 1269366784 bytes
Fixed Size                  2227984 bytes
Variable Size             805306608 bytes
Database Buffers          452984832 bytes
Redo Buffers                8847360 bytes
Database mounted.
ORA-03113: end-of-file on communication channel
Process ID: 20768
Session ID: 96 Serial number: 3


  • 4、查看alert日志
Wed Nov 06 10:30:55 2013
ARC3 started with pid=23, OS id=20926 
ARC1: Archival started
ARC2: Archival started
ARC1: Becoming the 'no FAL' ARCH
ARC1: Becoming the 'no SRL' ARCH
ARC2: Becoming the heartbeat ARCH
Errors in file /u01/app/oracle/diag/rdbms/test1107/test1107/trace/test1107_lgwr_20878.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/test1107/redo03a.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/test1107/redo03.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/test1107/test1107/trace/test1107_lgwr_20878.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/test1107/redo03a.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/test1107/redo03.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/test1107/test1107/trace/test1107_ora_20895.trc:
ORA-00313: open failed for members of log group 1 of thread 
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/test1107/redo03.log'
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/test1107/redo03a.log'
USER (ospid: 20895): terminating the instance due to error 313
System state dump requested by (instance=1, osid=20895), summary=[abnormal instance termination].
System State dumped to trace file /u01/app/oracle/diag/rdbms/test1107/test1107/trace/test1107_diag_20868.trc
Dumping diagnostic data in directory=[cdmp_20131106103056], requested by (instance=1, osid=20895), summary=[abnormal instance termination].
Instance terminated by USER, pid = 20895


  • 5、关闭数据库,重新启动到mount状态
dle> shutdown abort
ORACLE instance shut down.
idle> startup mount
ORACLE instance started.

Total System Global Area 1269366784 bytes
Fixed Size                  2227984 bytes
Variable Size             805306608 bytes
Database Buffers          452984832 bytes
Redo Buffers                8847360 bytes
Database mounted.

  • 6、删除整个INACTIVE的日志组,然后查看目前的日志组极其成员的状态
idle> alter database drop logfile group 3;

Database altered.

idle> set linesize 200
idle> col member for a50
idle> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIME         NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------------ ------------ ------------------
         2          1         20   52428800        512          2 NO  CURRENT                1132964 06-NOV-13            2.8147E+14
         1          1         18   52428800        512          2 YES INACTIVE               1132950 06-NOV-13               1132957 06-NOV-13

idle> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                                             IS_
---------- ------- ------- -------------------------------------------------- ---
         2         ONLINE  /u01/app/oracle/oradata/test1107/redo02.log        NO
         1         ONLINE  /u01/app/oracle/oradata/test1107/redo01.log        NO
         1         ONLINE  /u01/app/oracle/oradata/test1107/redo01a.log       NO
         2         ONLINE  /u01/app/oracle/oradata/test1107/redo02a.log       NO

  • 7、重新创建日志组3
idle> alter database add logfile group 3 ('/u01/app/oracle/oradata/test1107/redo03.log','/u01/app/oracle/oradata/test1107/redo03a.log') size 52428800;

Database altered.
  • 8、然后打开数据库,查询日志组极其成员

idle> alter database open;
                                                                                                                                                    
Database altered.

idle> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIME         NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------------ ------------ ------------------
         1          1         18   52428800        512          2 YES INACTIVE               1132950 06-NOV-13               1132957 06-NOV-13
         2          1         20   52428800        512          2 YES INACTIVE               1132964 06-NOV-13               1153041 06-NOV-13
         3          1         21   52428800        512          2 NO  CURRENT                1153041 06-NOV-13            2.8147E+14

idle> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                                             IS_
---------- ------- ------- -------------------------------------------------- ---
         3         ONLINE  /u01/app/oracle/oradata/test1107/redo03.log        NO
         2         ONLINE  /u01/app/oracle/oradata/test1107/redo02.log        NO
         1         ONLINE  /u01/app/oracle/oradata/test1107/redo01.log        NO
         1         ONLINE  /u01/app/oracle/oradata/test1107/redo01a.log       NO
         2         ONLINE  /u01/app/oracle/oradata/test1107/redo02a.log       NO
         3         ONLINE  /u01/app/oracle/oradata/test1107/redo03a.log       NO

6 rows selected.

idle> conn /as sysdba
Connected.
sys@TEST1107> 

你可能感兴趣的:(Oracle RMAN 使用RMAN恢复INACTIVE状态的日志)