• 模拟controfile丢失与重建


    --模拟controlfile丢失与重建
    ----------------------------------------------------------------2013/09/21
    1. 关闭数据库。
    2. 将controlfile重命名模拟丢失。
    [Oracle@localhost august]$ mv control01.ctl control01.ctl_bkp
    [Oracle@localhost august]$ mv control02.ctl control02.ctl_bkp
    3. 使用rman启动数据库。
    RMAN> startup mount;
    Oracle instance started
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of startup command at 09/20/2013 20:03:34
    ORA-00205: error in identifying control file, check alert log for more info
    没有control file只能启动到nomount状态。
     
    4. 即使没有控制文件,RMAN还是能识别自己的autobackup目录,可以直接使用下面命令
    RMAN> restore controlfile to '/u01/app/oracle/oradata/august/august/control01.ctl' from autobackup;
    我们可以也通过直接指定自动备份集来进行恢复。
    RMAN> restore controlfile to '/u01/app/oracle/oradata/august/august/control01.ctl' from '/u01/app/oracle/flash_recovery_area/august/AUGUST/autobackup/2013_09_20/o1_mf_s_826618674_93rss9os_.bkp';
     
    Starting restore at 20-SEP-13
    using channel ORA_DISK_1
     
    channel ORA_DISK_1: restoring control file
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
    Finished restore at 20-SEP-13
     
    启动数据库到mount
     
    RMAN> alter database mount;
     
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of alter db command at 09/20/2013 20:22:24
    ORA-00205: error in identifying control file, check alert log for more info
     
    --因为ORACLE这里要求所有的控制的文件都要被一致的恢复,在此数据库中有两份控制文件,我们这里只恢复了一份,它不能识别。这些信息在参数文件中指定好了。
    RMAN>  restore controlfile to '/u01/app/oracle/flash_recovery_area/august/august/control02.ctl' from autobackup;
     
    Starting restore at 20-SEP-13
    using channel ORA_DISK_1
     
    recovery area destination: /u01/app/oracle/flash_recovery_area/august
    database name (or database unique name) used for search: AUGUST
    channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/flash_recovery_area/august/AUGUST/autobackup/2013_09_20/o1_mf_s_826618674_93rss9os_.bkp found in the recovery area
    channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130920
    channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/flash_recovery_area/august/AUGUST/autobackup/2013_09_20/o1_mf_s_826618674_93rss9os_.bkp
    channel ORA_DISK_1: control file restore from AUTOBACKUP complete
    Finished restore at 20-SEP-13
     
    RMAN> alter database mount;
     
    database mounted
    released channel: ORA_DISK_1
     
    恢复另一份控制文件后,就可以正常mount了。
     
    或者我们可以直接采用下面这种方式,ORACLE自己决定恢复的目录。
     
    RMAN> restore controlfile from '/u01/app/oracle/flash_recovery_area/august/AUGUST/autobackup/2013_09_20/o1_mf_s_826618674_93rss9os_.bkp';
     
    Starting restore at 20-SEP-13
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=19 device type=DISK
     
    channel ORA_DISK_1: restoring control file
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
    output file name=/u01/app/oracle/oradata/august/august/control01.ctl
    output file name=/u01/app/oracle/flash_recovery_area/august/august/control02.ctl
    Finished restore at 20-SEP-13
     
    RMAN> alter database mount;
     
    database mounted
    released channel: ORA_DISK_1
     
    由于控制文件恢复,进行数据库恢复,同步文件信息。
     
    RMAN> recover database;
     
    Starting recover at 20-SEP-13
    Starting implicit crosscheck backup at 20-SEP-13
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=19 device type=DISK
    Crosschecked 3 objects
    Finished implicit crosscheck backup at 20-SEP-13
     
    Starting implicit crosscheck copy at 20-SEP-13
    using channel ORA_DISK_1
    Finished implicit crosscheck copy at 20-SEP-13
     
    searching for all files in the recovery area
    cataloging files...
    cataloging done
     
    List of Cataloged Files
    =======================
    File Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/autobackup/2013_09_20/o1_mf_s_826618674_93rss9os_.bkp
     
    using channel ORA_DISK_1
    /*完成更新同步控制文件中的备份信息*/
    starting media recovery
     
    archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oracle/oradata/august/august/redo01.log
    archived log file name=/u01/app/oracle/oradata/august/august/redo01.log thread=1 sequence=1
    media recovery complete, elapsed time: 00:00:09
    Finished recover at 20-SEP-13
    /*完成介质恢复*/
     
    --转储数据文件头文件
    SQL> alter session set events 'immediate trace name file_hdrs level 10';
     
    *** 2013-09-20 21:06:30.810
    DUMP OF DATA FILES: 4 files in database
     
    DATA FILE #1:
      name #7: /u01/app/oracle/oradata/august/august/system01.dbf
    creation size=0 block size=8192 status=0xe head=7 tail=7 dup=1
     tablespace 0, index=1 krfil=1 prev_file=0
     unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
     Checkpoint cnt:105 scn: 0x0000.000d0471 09/20/2013 19:59:32    /*853105 : <1> 845017 --2.8147E+14 1号日志文件*/
     Stop scn: 0x0000.000d0471 09/20/2013 19:59:32
     
    --转储新的控制信息
     
    -DATABASE
    Database checkpoint: Thread=1 scn: 0x0000.000ce4dc /*847180*/
    -CHECKPOINT
    low cache rba:(0x1.3.0) on disk rba:(0x1.72.0)
    on disk scn: 0x0000.000ce57a 09/20/2013 08:17:51  /*845178*/  /*检查点都没有得到更新,数据库还没打开也可以理解*/
    -DATAFILE
    Checkpoint cnt:105 scn: 0x0000.000d0471 09/20/2013 19:59:32
     Stop scn: 0x0000.000d0471 09/20/2013 19:59:32    /*datafile的信息都同步为最新*/
     
    --打开数据库
     
    RMAN> alter database open;
     
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of alter db command at 09/20/2013 20:59:08
    ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
     
    RMAN> alter database open noresetlogs;
     
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00558: error encountered while parsing input commands
    RMAN-01009: syntax error: found "identifier": expecting one of: "resetlogs, ;"
    RMAN-01008: the bad identifier was: noresetlogs
    RMAN-01007: at line 1 column 21 file: standard input
     
    --可见即使信息同步了,我们也只能以resetlogs方式打开数据库。这里需要指出常见的几种情况,需要以resetlogs方式打开数据库。
    1. 在执行了不完全恢复之后。
    2. 在使用了备份的控制文件进行恢复后。
    3. 使用带有resetlogs选项创建的控制文件恢复之后。
     
    RMAN> alter database open resetlogs;
     
    database opened
     
     
  • 相关阅读:
    团队作业第四次—项目系统设计与数据库设计
    团队作业第三次—项目需求分析
    简时——alpha冲刺任务七(5.5)
    简时——alpha冲刺任务六(5.4)
    简时——alpha冲刺任务五(5.3)
    简时——alpha冲刺任务四(5.2)
    简时——alpha冲刺任务三(5.1)
    简时——alpha冲刺日志二(4.30)
    简时——alpha冲刺日志一(4.29)
    TimeMaster—代码规范、冲刺任务与计划
  • 原文地址:https://www.cnblogs.com/jackhub/p/3331343.html
Copyright © 2020-2023  润新知