Oracle 11g RAMN恢復-控制檔案的備份和恢復

yuntui發表於2016-11-03

--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部落格 ” ,連結:http://blog.itpub.net/30633755/viewspace-2127659/,如需轉載,請註明出處,否則將追究法律責任。

相關文章