当没有使用恢复目录时,必须从控制文件自动备份中还原控制文件。如果从控制文件自动备份中还原控制文件,数据库必须置于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参数所指定的所有位置