rman還原控制檔案(二)

eric0435發表於2015-02-02

當沒有使用恢復目錄時,必須從控制檔案自動備份中還原控制檔案。如果從控制檔案自動備份中還原控制檔案,資料庫必須置於nomount狀態。必須首先設定資料庫的DBID,然後執行restore controlfile from autobackup命令

1.人為刪除所有控制檔案

[root@oracle11g test]# ls -lrt
total 2213868
-rw-r----- 1 oracle oinstall  20979712 Feb  1 11:37 temp01.dbf
-rw-r----- 1 oracle oinstall  11804672 Feb  1 22:31 users01.dbf
-rw-r----- 1 oracle oinstall  52436992 Feb  1 22:31 test01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:31 redo03.log
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:31 redo02.log
-rw-r----- 1 oracle oinstall 104865792 Feb  1 22:31 example01.dbf
-rw-r----- 1 oracle oinstall 576724992 Feb  1 22:37 sysaux01.dbf
-rw-r----- 1 oracle oinstall 492838912 Feb  1 22:42 undotbs01.dbf
-rw-r----- 1 oracle oinstall 838868992 Feb  1 22:42 system01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:42 redo01.log
-rw-r----- 1 oracle oinstall   9814016 Feb  1 22:42 control03.ctl
-rw-r----- 1 oracle oinstall   9814016 Feb  1 22:42 control02.ctl
-rw-r----- 1 oracle oinstall   9814016 Feb  1 22:42 control01.ctl
[root@oracle11g test]# rm -rf control*.ctl
[root@oracle11g test]# ls -lrt
total 2185068
-rw-r----- 1 oracle oinstall  20979712 Feb  1 11:37 temp01.dbf
-rw-r----- 1 oracle oinstall  11804672 Feb  1 22:31 users01.dbf
-rw-r----- 1 oracle oinstall  52436992 Feb  1 22:31 test01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:31 redo03.log
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:31 redo02.log
-rw-r----- 1 oracle oinstall 104865792 Feb  1 22:31 example01.dbf
-rw-r----- 1 oracle oinstall 576724992 Feb  1 22:37 sysaux01.dbf
-rw-r----- 1 oracle oinstall 492838912 Feb  1 22:42 undotbs01.dbf
-rw-r----- 1 oracle oinstall 838868992 Feb  1 22:42 system01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:42 redo01.log

2.人為將資料庫異常終止

[root@oracle11g test]# ps -ef | grep smon
oracle    3063     1  0 22:30 ?        00:00:00 ora_smon_test
root      3179  3123  0 22:45 pts/3    00:00:00 grep smon
[root@oracle11g test]# kill -9 3063

3.將資料庫啟動到nomount狀態

SQL> startup nomount
ORACLE instance started.

Total System Global Area  327155712 bytes
Fixed Size                  1273516 bytes
Variable Size             138412372 bytes
Database Buffers          184549376 bytes
Redo Buffers                2920448 bytes

4.從以前的備份資訊中可以找到如下資訊,其中c-2155613261-20150201-03中的2155613261就是DBID

Starting Control File and SPFILE Autobackup at 01-FEB-15
piece handle=/u01/app/oracle/10.2.0/db/dbs/c-2155613261-20150201-03 comment=NONE
Finished Control File and SPFILE Autobackup at 01-FEB-15

5.還原控制檔案

RMAN> show controlfile autobackup format;

RMAN configuration parameters are:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE 'STB' TO '%F';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE 'SBT_TAPE' TO '%F';

RMAN> set dbid 2155613261;

executing command: SET DBID

RMAN> restore controlfile from autobackup;

Starting restore at 01-FEB-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

recovery area destination: /u01/app/oracle/flash_recovery_area
database name (or database unique name) used for search: TEST
channel ORA_DISK_1: no autobackups found in the recovery area
channel ORA_DISK_1: looking for autobackup on day: 20150201
channel ORA_DISK_1: autobackup found: c-2155613261-20150201-03
channel ORA_DISK_1: control file restore from autobackup complete
output filename=/u01/app/oracle/oradata/test/control01.ctl
output filename=/u01/app/oracle/oradata/test/control02.ctl
output filename=/u01/app/oracle/oradata/test/control03.ctl
Finished restore at 01-FEB-15

6.恢復資料庫

RMAN> sql 'alter database mount';

sql statement: alter database mount
released channel: ORA_DISK_1

RMAN> recover database;

Starting recover at 01-FEB-15
Starting implicit crosscheck backup at 01-FEB-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
Crosschecked 13 objects
Finished implicit crosscheck backup at 01-FEB-15

Starting implicit crosscheck copy at 01-FEB-15
using channel ORA_DISK_1
Crosschecked 6 objects
Finished implicit crosscheck copy at 01-FEB-15

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 2 is already on disk as file /u01/app/oracle/oradata/test/redo02.log
archive log thread 1 sequence 3 is already on disk as file /u01/app/oracle/oradata/test/redo03.log
archive log filename=/u01/app/oracle/oradata/test/redo02.log thread=1 sequence=2
archive log filename=/u01/app/oracle/oradata/test/redo03.log thread=1 sequence=3
media recovery complete, elapsed time: 00:00:03
Finished recover at 01-FEB-15

RMAN> sql 'alter database open resetlogs';

sql statement: alter database open resetlogs

RMAN會使用自動備份的格式與DBID來判斷在什麼儲存位置來搜尋控制檔案自動備份。如果找到,RMAN就會從備份中將控制檔案還原到由control_files引數所指定的所有位置

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-1423245/,如需轉載,請註明出處,否則將追究法律責任。

相關文章