rman实验之归档模式有备份,正常关机丢失控制文件的恢复
在恢复控制文件之前,必须知道目标数据库的DBID。身为DBA的你,在接手数据库时,定要把数据库的DBID给备份出来!
1)备份控制文件
RMAN> list backup of controlfile;
2)测试数据
hr@ORCL> create table t (name varchar2(20));Table created.hr@ORCL> insert into t values('think');1 row created.hr@ORCL> commit;Commit complete.
3)模拟环境
sys@ORCL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.sys@ORCL> host rm -rf /u01/app/oracle/oradata/ORCL/controlfile/*sys@ORCL> startup ORACLE instance started.Total System Global Area 419430400 bytesFixed Size 1219760 bytesVariable Size 150995792 bytesDatabase Buffers 264241152 bytesRedo Buffers 2973696 bytesORA-00205: error in identifying control file, check alert log for more info
由于控制文件丢失,肯定是启动不到mount状态了。
4)修复控制文件
因为nocatalog下,rman的备份信息及环境配置等都在控制文件里,而控制文件又丢失了,所以以前你对rman做的很多自定义设置都没有了,包括自动备份。
RMAN> set DBID=1316499950executing command: SET DBIDRMAN> restore controlfile from '/u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_08_08/o1_mf_ncnnf_TAG20120808T101321_823lt24m_.bkp';Starting restore at 08-AUG-12using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: sid=155 devtype=DISKchannel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:02output filename=/u01/app/oracle/oradata/ORCL/controlfile/o1_mf_823mrrdo_.ctloutput filename=/u01/app/oracle/flash_recovery_area/ORCL/controlfile/o1_mf_823mrrrp_.ctlFinished restore at 08-AUG-12RMAN> alter database mount;database mountedreleased channel: ORA_DISK_1
5)恢复数据库
由于数据文件都在,只需要重新运用备份控制文件之后生成的那些重做日志文件即可
RMAN> recover database;
6)resetlogs打开数据库
由于通过备份的控制文件恢复,因此打开时必须指定resetlogs
RMAN> alter database open resetlogs;database openedRMAN> list incarnation of database;List of Database IncarnationsDB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time------- ------- -------- ---------------- --- ---------- ----------1 1 ORCL 1316499950 PARENT 1 30-JUN-052 2 ORCL 1316499950 PARENT 446075 15-JUL-123 3 ORCL 1316499950 CURRENT 604802 08-AUG-12
7)查询数据
hr@ORCL> select * from t;NAME--------------------think
ok,everything is perfect。