ITPub博客

首页 > 数据库 > Oracle > Oracle 11g RAMN恢复-控制文件的备份和恢复

Oracle 11g RAMN恢复-控制文件的备份和恢复

Oracle 作者:yuntui 时间:2016-11-03 20:03:18 0 删除 编辑

--0. 场景模拟

--0.1 查看对控制文件的备份

RMAN> list backup of controlfile;

 

 

List of Backup Sets

===================

 

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

89      Full    9.95M      DISK        00:00:01     14-AUG-13     

        BP Key: 89   Status: AVAILABLE  Compressed: NO  Tag: TAG20130814T184100

        Piece Name: /u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823459260_90r5dfgj_.bkp

  Control File Included: Ckp SCN: 2783451      Ckp time: 14-AUG-13

 

--0.2 不放心,再重新备份一个

RMAN> backup current controlfile;

 

Starting backup at 14-AUG-13

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

channel ORA_DISK_1: starting piece 1 at 14-AUG-13

channel ORA_DISK_1: finished piece 1 at 14-AUG-13

piece handle=/pooldisk02/backup03/3goha0fk_1_1 tag=TAG20130814T185900 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 14-AUG-13

 

Starting Control File and SPFILE Autobackup at 14-AUG-13

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823460342_90r6g6dq_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 14-AUG-13

--0.3 再次查看备份的控制文件

RMAN> list backup of controlfile;

 

 

List of Backup Sets

===================

 

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

89      Full    9.95M      DISK        00:00:01     14-AUG-13     

        BP Key: 89   Status: AVAILABLE  Compressed: NO  Tag: TAG20130814T184100

        Piece Name: /u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823459260_90r5dfgj_.bkp

  Control File Included: Ckp SCN: 2783451      Ckp time: 14-AUG-13

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

90      Full    9.92M      DISK        00:00:01     14-AUG-13     

        BP Key: 90   Status: AVAILABLE  Compressed: NO  Tag: TAG20130814T185900

        Piece Name: /pooldisk02/backup03/3goha0fk_1_1

  Control File Included: Ckp SCN: 2784575      Ckp time: 14-AUG-13

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

91      Full    9.95M      DISK        00:00:00     14-AUG-13     

        BP Key: 91   Status: AVAILABLE  Compressed: NO  Tag: TAG20130814T185902

        Piece Name: /u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823460342_90r6g6dq_.bkp

  Control File Included: Ckp SCN: 2784582      Ckp time: 14-AUG-13

 

--0.4 关库

sys@TESTDB11>shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down. 

--0.5 移除控制文件,注意是2个

sys@TESTDB11>show parameter control_files

 

NAME                                 TYPE        VALUE

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

control_files                        string      /u01/app/oracle/oradata/TestDB

                                                 11/control01.ctl, /u01/app/ora

                                                 cle/fast_recovery_area/TestDB1

                                                 1/control02.ctl

--0.6 控制文件损坏

sys@TESTDB11>!mv /u01/app/oracle/oradata/TestDB11/control01.ctl /export/home/oracle

 

sys@TESTDB11>!mv /u01/app/oracle/fast_recovery_area/TestDB11/control02.ctl /export/home/oracle 

 

--0.7 启库

sys@TESTDB11>startup;

ORACLE instance started.

 

Total System Global Area  855982080 bytes

Fixed Size                  2230792 bytes

Variable Size             742393336 bytes

Database Buffers          109051904 bytes

Redo Buffers                2306048 bytes

ORA-00205: error in identifying control file, check alert log for more info

 

--1. rman连接,显示momount,因此查询备份list backup进行不了

[oracle@S1011:/export/home/oracle]$ rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Aug 14 19:11:12 2013

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: TESTDB11 (not mounted)

 

RMAN> list backup;

 

using target database control file instead of recovery catalog

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of list command at 08/14/2013 19:11:24

ORA-01507: database not mounted

 

--2. 先还原控制文件

--方法2.a:前提是备份的目的地有一个是快速恢复区

RMAN> restore controlfile from autobackup;

 

Starting restore at 14-AUG-13

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=21 device type=DISK

 

recovery area destination: /u01/app/oracle/fast_recovery_area

database name (or database unique name) used for search: TESTDB11

channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823460342_90r6g6dq_.bkp found in the recovery area

AUTOBACKUP search with format "%F" not attempted because DBID was not set

channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823460342_90r6g6dq_.bkp

channel ORA_DISK_1: control file restore from AUTOBACKUP complete

output file name=/u01/app/oracle/oradata/TestDB11/control01.ctl

output file name=/u01/app/oracle/fast_recovery_area/TestDB11/control02.ctl

Finished restore at 14-AUG-13

 

--方法2.b ,前提是得知道,备份的控制文件,备份片的名称

RMAN> restore controlfile from '/pooldisk02/backup03/3goha0fk_1_1';

 

Starting restore at 14-AUG-13

using channel ORA_DISK_1

 

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

output file name=/u01/app/oracle/oradata/TestDB11/control01.ctl

output file name=/u01/app/oracle/fast_recovery_area/TestDB11/control02.ctl

Finished restore at 14-AUG-13

 

--3. 此时直接开库出错

RMAN> open database;

 

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of alter db command at 08/14/2013 19:22:58

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

--4. 进行恢复(虽然数据文件没有问题,但控制文件与数据文件检查点SCN不一致)

RMAN> recover database;

 

Starting recover at 14-AUG-13

Starting implicit crosscheck backup at 14-AUG-13

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=21 device type=DISK

Crosschecked 2 objects

Finished implicit crosscheck backup at 14-AUG-13

 

Starting implicit crosscheck copy at 14-AUG-13

using channel ORA_DISK_1

Finished implicit crosscheck copy at 14-AUG-13

 

searching for all files in the recovery area

cataloging files...

cataloging done

 

List of Cataloged Files

=======================

File Name: /u01/app/oracle/fast_recovery_area/TESTDB11/autobackup/2013_08_14/o1_mf_s_823460342_90r6g6dq_.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/TestDB11/redo01.log

archived log file name=/u01/app/oracle/oradata/TestDB11/redo01.log thread=1 sequence=1

media recovery complete, elapsed time: 00:00:00

Finished recover at 14-AUG-13

--5. 开库

RMAN> sql 'alter database open resetlogs';

 

sql statement: alter database open resetlogs

 

--6. 删除原有备份,创建新的备份

RMAN> delete backup;

RMAN> backup database;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30633755/viewspace-2127659/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2015-12-14

  • 博文量
    150
  • 访问量
    70828