zoukankan      html  css  js  c++  java
  • 历史备份控制文件恢复数据库

    oracle 10g 以后允许在不同的incarnation之间进行完全/不完全恢复。在参数文件log_archive_format中多了一个%r格式符号,这是
    resetlogs的标志号,这一归档模式避免不同incarnation的归档相互覆盖,从而使得跨越resetlogs恢复的日记基础得以保证。


    RMAN> list incarnation; List of Database Incarnations DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time ------- ------- -------- ---------------- --- ---------- ---------- 1 1 ORCL 1358813460 PARENT 1 15-AUG-09 2 2 ORCL 1358813460 PARENT 945184 09-NOV-13 3 3 ORCL 1358813460 CURRENT 2181557 29-DEC-13
    select thread#,sequence#,first_change#,next_change# from v$archived_log;
         2       55        2140766     2172246
         2       56        2172246     2181556
         2        1        2181557     2203709
    
       THREAD#  SEQUENCE# FIRST_CHANGE# NEXT_CHANGE#
    ---------- ---------- ------------- ------------
         2        2        2203709     2224422
         2        3        2224422     2258307
         2        4        2258307     2258311
         1        1        2237798     2280109
         1        2        2280109     2280114
         1        3        2280114     2280116
         2        5        2280111     2280131
         1        4        2280116     2280127

    SQL> select thread#,sequence#,status from v$log;
    
       THREAD#  SEQUENCE# STATUS
    ---------- ---------- ----------------
         1        3 INACTIVE
         1        4 ACTIVE
         2        5 INACTIVE
         2        6 CURRENT

    以上是原控制文件的信息。同时参照V$log_history视图。

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

    RMAN> restore controlfile from '/home/oracle/c.ctl';
    
    Starting restore at 31-DEC-13
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=17 instance=orcl2 device type=DISK
    
    channel ORA_DISK_1: copied control file copy
    output file name=+DATA/orcl/controlfile/current.260.835608817
    output file name=+FRA/orcl/controlfile/current.256.835608825
    Finished restore at 31-DEC-13
    
    RMAN> list incarnation;
    
    released channel: ORA_DISK_1
    
    List of Database Incarnations
    DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
    ------- ------- -------- ---------------- --- ---------- ----------
    1       1       ORCL     1358813460       PARENT  1          15-AUG-09
    2       2       ORCL     1358813460       CURRENT 945184     09-NOV-13

    尝试rman 恢复

    RMAN> recover database;
    
    Starting recover at 31-DEC-13
    Starting implicit crosscheck backup at 31-DEC-13
    allocated channel: ORA_DISK_1
    Finished implicit crosscheck backup at 31-DEC-13
    
    Starting implicit crosscheck copy at 31-DEC-13
    using channel ORA_DISK_1
    Crosschecked 2 objects
    Finished implicit crosscheck copy at 31-DEC-13
    
    searching for all files in the recovery area
    cataloging files...
    cataloging done
    
    List of Cataloged Files
    =======================
    File Name: +fra/ORCL/BACKUPSET/2013_12_31/ncnnf0_TAG20131231T092954_0.296.835608605
    ……
    …… // 自动根据参数db_recovery_file_dest指定的目录中去寻找可用文件
    File Name: +fra/ORCL/AUTOBACKUP/2013_12_31/thread_1_seq_2.292.835607377
    File Name: +fra/ORCL/ARCHIVELOG/2013_12_31/thread_1_seq_3.293.835607395
    File Name: +fra/ORCL/ARCHIVELOG/2013_12_31/thread_2_seq_5.294.835607395
    File Name: +fra/ORCL/ARCHIVELOG/2013_12_31/thread_1_seq_4.295.835607399
    
    using channel ORA_DISK_1
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of recover command at 12/31/2013 09:36:12
    RMAN-06094: datafile 8 must be restored  
    //提示datafile 8 缺失,手动删除过。
    RMAN> recover database skip tablespace wayde;
    
    Starting recover at 31-DEC-13
    using channel ORA_DISK_1
    
    Executing: alter database datafile 8 offline
    starting media recovery
    ……
    media recovery complete, elapsed time: 00:00:16
    Finished recover at 31-DEC-13
    
    RMAN> list incarnation;
    
    
    List of Database Incarnations
    DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
    ------- ------- -------- ---------------- --- ---------- ----------
    1       1       ORCL     1358813460       PARENT  1          15-AUG-09
    2       2       ORCL     1358813460       PARENT  945184     09-NOV-13
    3       3       ORCL     1358813460       CURRENT 2181557    29-DEC-13

    结论:在用历史控制文件恢复数据库的时候,如果在历史控制文件后又新添加了‘表空间’,“日志文件(不是active或者current状态)”,“控制文件中有但是实际没有” 在恢复的时候,会重新建表空间,日志以控制文件为准儿。如果在备份了控制文件之后手动删除了表空间,那么在恢复的时候要先把数据文件offline(sql语句) 或者 直接  RMAN> recover database skip tablespace wayde;

  • 相关阅读:
    Tarjan算法
    10JS数组
    9JS循环
    8.JS流程控制
    7.JS运算符
    6.JS方法
    5.JS变量的各种问题
    java封装遇到的问题
    js报Uncaught SyntaxError: Unexpected token <错误 解决方法:
    使用layui出现Uncaught ReferenceError: layui is not defined问题解决:
  • 原文地址:https://www.cnblogs.com/51linux/p/3498926.html
Copyright © 2011-2022 走看看