• Oracle RMAN 使用RMAN恢复ACTIVE状态的日志


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

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

    • 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         22   52428800        512          2 NO  CURRENT                1153754
    06-NOV-13            2.8147E+14

             2          1         20   52428800        512          2 YES INACTIVE               1132964
    06-NOV-13               1153041 06-NOV-13

             3          1         21   52428800        512          2 YES ACTIVE                 1153041
    06-NOV-13               1153754 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. ACTIVE 组日志是第3组,OS下删除第三组的其中一个成员                

    [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.
    Database opened.

    • 4、查看alert日志
    Errors in file /u01/app/oracle/diag/rdbms/test1107/test1107/trace/test1107_lgwr_23973.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/redo03.log'
    ORA-27037: unable to obtain file status
    Linux-x86_64 Error: 2: No such file or directory

    • 5、查看数据库打开后的日志组以及日志成员状态,发现刚才删掉的那个日志成员的状态为INVALID 。
    sys@TEST1107> select * from v$log;

        GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE#
    ---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- -------------
    FIRST_TIME         NEXT_CHANGE# NEXT_TIME
    ------------------ ------------ ------------------
             1          1         22   52428800        512          2 YES INACTIVE               1153754
    06-NOV-13               1174308 06-NOV-13

             2          1         23   52428800        512          2 NO  CURRENT                1174308
    06-NOV-13            2.8147E+14

             3          1         21   52428800        512          2 YES INACTIVE               1153041
    06-NOV-13               1153754 06-NOV-13


    sys@TEST1107> select * from v$logfile;

        GROUP# STATUS  TYPE    MEMBER                                             IS_
    ---------- ------- ------- -------------------------------------------------- ---
             3 INVALID 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.

    • 6、解决办法为drop后重新添加
    sys@TEST1107> alter database drop logfile member '/u01/app/oracle/oradata/test1107/redo03.log';

    Database altered.

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

    Database altered.
    • 7、再次查看日志组以及日志组成员,发现还是INVALID状态。

    sys@TEST1107> select * from v$log;

        GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE#
    ---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- -------------
    FIRST_TIME         NEXT_CHANGE# NEXT_TIME
    ------------------ ------------ ------------------
             1          1         22   52428800        512          2 YES INACTIVE               1153754
    06-NOV-13               1174308 06-NOV-13

             2          1         23   52428800        512          2 NO  CURRENT                1174308
    06-NOV-13            2.8147E+14

             3          1         21   52428800        512          2 YES INACTIVE               1153041
    06-NOV-13               1153754 06-NOV-13


    sys@TEST1107> select * from v$logfile;

        GROUP# STATUS  TYPE    MEMBER                                             IS_
    ---------- ------- ------- -------------------------------------------------- ---
             3 INVALID 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.
    • 8、切换日志,使其强制使用,再次查看,日志成员已恢复正常。
    sys@TEST1107> 
    sys@TEST1107> alter system switch logfile;

    System altered.

    sys@TEST1107> /

    System altered.

    sys@TEST1107> /

    System altered.

    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恢复acitve日志组的所有成员损坏


    • 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         25   52428800        512          2 YES INACTIVE               1175094
    06-NOV-13               1175097 06-NOV-13

             2          1         26   52428800        512          2 YES ACTIVE                 1175097
    06-NOV-13               1178906 06-NOV-13

             3          1         27   52428800        512          2 NO  CURRENT                1178906
    06-NOV-13            2.8147E+14


    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、删除ACTIVE日志组所有成员

    [oracle@rtest ~]$ rm /u01/app/oracle/oradata/test1107/redo02.log
    [oracle@rtest ~]$ rm /u01/app/oracle/oradata/test1107/redo02a.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: 1466
    Session ID: 96 Serial number: 3

    • 4、查看alert告警日志

    Wed Nov 06 11:43:25 2013
    ARC3 started with pid=23, OS id=1610 
    ARC1: Archival started
    ARC2: Archival started
    ARC2: Becoming the 'no FAL' ARCH
    ARC2: Becoming the 'no SRL' ARCH
    ARC1: Becoming the heartbeat ARCH
    Errors in file /u01/app/oracle/diag/rdbms/test1107/test1107/trace/test1107_lgwr_1565.trc:
    ORA-00313: open failed for members of log group 2 of thread 1
    ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/test1107/redo02a.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 2 thread 1: '/u01/app/oracle/oradata/test1107/redo02.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_1565.trc:
    ORA-00313: open failed for members of log group 2 of thread 1
    ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/test1107/redo02a.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 2 thread 1: '/u01/app/oracle/oradata/test1107/redo02.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_1582.trc:
    ORA-00313: open failed for members of log group 1 of thread 
    ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/test1107/redo02.log'
    ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/test1107/redo02a.log'
    USER (ospid: 1582): terminating the instance due to error 313
    System state dump requested by (instance=1, osid=1582), summary=[abnormal instance termination].
    System State dumped to trace file /u01/app/oracle/diag/rdbms/test1107/test1107/trace/test1107_diag_1555.trc
    Dumping diagnostic data in directory=[cdmp_20131106114326], requested by (instance=1, osid=1582), summary=[abnormal instance termination].
    Instance terminated by USER, pid = 1582

    • 5、直接关闭不行,退出重新以mount模式登进

    sys@TEST1107> shutdown abort
    ORA-24324: service handle not initialized
    ORA-01041: internal error. hostdef extension doesn't exist
    sys@TEST1107> quit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    [oracle@rtest ~]$ sqlplus "/as sysdba"

    SQL*Plus: Release 11.2.0.3.0 Production on Wed Nov 6 11:54:02 2013

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

    Connected to an idle instance.

    idle> 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、使用隐藏参数,进行不一致的恢复
    idle> alter system set "_allow_resetlogs_corruption"=true scope=spfile;

    System altered.
    • 7、重启,mount方式起库,使隐藏参数生效
    idle> shutdown immediate
    ORA-01109: database not open


    Database dismounted.
    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.
    • 7、使用基于取消的数据库恢复
    idle> recover database until cancel;
    Media recovery complete.
    • 8、使用resetlogs方式打开数据库
    idle> alter database open resetlogs;

    Database altered.


    • 9、查看恢复后的日志组及其成员
    sys@TEST1107> select * from v$log;

        GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE#
    ---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- -------------
    FIRST_TIME         NEXT_CHANGE# NEXT_TIME
    ------------------ ------------ ------------------
             1          1          1   52428800        512          2 NO  CURRENT                1199286
    06-NOV-13            2.8147E+14

             2          1          0   52428800        512          2 YES UNUSED                       0
                                  0

             3          1          0   52428800        512          2 YES UNUSED                       0
                                  0


    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.

    • 10、切换日志,更改日志组状态

    sys@TEST1107> alter system switch logfile;

    System altered.

    sys@TEST1107> alter system switch logfile;

    System altered.

    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          4   52428800        512          2 NO  CURRENT                1200058
    06-NOV-13            2.8147E+14

             2          1          2   52428800        512          2 YES INACTIVE               1200052
    06-NOV-13               1200055 06-NOV-13

             3          1          3   52428800        512          2 YES INACTIVE               1200055
    06-NOV-13               1200058 06-NOV-13


    sys@TEST1107> 
  • 相关阅读:
    ARC071 简要题解
    ARC070 简要题解
    ARC069 简要题解
    ARC068 简要题解
    ARC067 简要题解
    ARC066 简要题解
    ARC065 简要题解
    长链剖分优化dp三例题
    CF815D Karen and Cards 官方题解翻译
    [九省联考2018] IIIDX 线段树+贪心
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13316535.html
Copyright © 2020-2023  润新知