4、开始恢复参数文件,只有恢复了参数文件和控制文件数据库才能到mount状态来恢复数据文件:
RMAN> restorespfile fromautobackup;
Starting restoreat 23-MAY-12
using targetdatabase control fileinstead of recovery catalog
allocatedchannel: ORA_DISK_1
channelORA_DISK_1: sid=36devtype=DISK
RMAN-00571:===========================================================
RMAN-00569:=============== ERRORMESSAGE STACK FOLLOWS ===============
RMAN-00571:===========================================================
RMAN-03002:failure of restorecommand at 05/23/2012 17:08:42
RMAN-06495: mustexplicitly specifyDBID with SET DBID command
RMAN>
注意:这里有问题了,spfile无法恢复,必须指定DBID。我记得在每次登录到rman的时候都会显示一个数据库的DBID,但是为什么这里要我们指定DBID呢???原因很简单,因为我们登录RMAN的时候,数据库已经宕机了,而且参数文件,控制文件,数据文件都没有了,它到哪里去找DBID;所以需要我们手动来指定,问题是现在既然登录的时候不显示,我们也不知道在哪里呀,如下:
[Oracle@wwldb dbs]$ rman target /
Recovery Manager: Release 10.2.0.1.0- Production on WedMay 23 17:06:32 2012
Copyright (c) 1982, 2005, Oracle. All rightsreserved.
connected to targetdatabase (not started)
没关系的因为我们的控制文件做了自动备份,在自动备份的控制文件里面已经存在了DBID,我们现在去找找吧,默认就备份在如下位置:
[oracle@wwldb dbs]$ pwd
/DBSoft/product/10.2.0/db_1/dbs
[oracle@wwldb dbs]$ ls
c-5520179-20120518-01c-5520179-20120523-01 hc_WWL.dat lkWWL
其中5520179就是DBID了,我们只需要通过指定这个DBID,就可以将spfile恢复并将数据库启动到mount状态。
RMAN> set DBID=5520179
executingcommand: SET DBID
RMAN> restore spfile fromautobackup;
Starting restoreat 23-MAY-12
using targetdatabase control fileinstead of recovery catalog
allocatedchannel: ORA_DISK_1
channelORA_DISK_1: sid=39devtype=DISK
channelORA_DISK_1: looking forautobackup on day: 20120523
channelORA_DISK_1: autobackup found:c-5520179-20120523-04
channelORA_DISK_1: SPFILE restorefrom autobackup complete
Finished restoreat 23-MAY-12
RMAN>
5、恢复控制文件
RMAN> restore controlfile fromautobackup;
Starting restoreat 23-MAY-12
using channelORA_DISK_1
channelORA_DISK_1: looking forautobackup on day: 20120523
channelORA_DISK_1: autobackup found:c-5520179-20120523-04
channelORA_DISK_1: control filerestore from autobackup complete
outputfilename=/DBSoft/product/10.2.0/db_1/dbs/cntrlWWL.dbf
Finished restoreat 23-MAY-12
RMAN>
重启数据库到mount状态---很重要
SQL> startup mount;
ORACLE instancestarted.
Total SystemGlobal Area 285212672bytes
Fixed Size 1218968 bytes
VariableSize 79693416 bytes
DatabaseBuffers 197132288 bytes
RedoBuffers 7168000 bytes
Databasemounted.
SQL> exit
Disconnectedfrom Oracle Database 10gEnterprise Edition Release 10.2.0.1.0 - Production
With thePartitioning, OLAP and DataMining options
[oracle@wwldb dbs]$ rman target /
RecoveryManager: Release 10.2.0.1.0- Production on Wed May 23 19:04:15 2012
Copyright (c)1982, 2005, Oracle. Allrights reserved.
connected totarget database: WWL(DBID=5520179, not open)
注意:详细参考如下:
http://blog.csdn.net/wuweilong/article/details/7596056
http://space.itpub.net/?uid-20674423-action-viewspace-itemid-730717
6、恢复数据库其它的数据文件:
RMAN> restore database;
Starting restoreat 23-MAY-12
using targetdatabase control fileinstead of recovery catalog
allocatedchannel: ORA_DISK_1
channelORA_DISK_1: sid=156devtype=DISK
channelORA_DISK_1: starting datafilebackupset restore
channelORA_DISK_1: specifying datafile(s)to restore from backup set
restoringdatafile 00004 to/DBData/WWL/users01.dbf
channelORA_DISK_1: reading frombackup piece /DBBak/bak_WWL_05_23_0cnbn2a3_1_1
channelORA_DISK_1: restored backuppiece 1
piecehandle=/DBBak/bak_WWL_05_23_0cnbn2a3_1_1tag=TAG20120523T133147
channelORA_DISK_1: restore complete,elapsed time: 00:00:02
channelORA_DISK_1: starting datafilebackupset restore
channelORA_DISK_1: specifyingdatafile(s) to restore from backup set
restoringdatafile 00001 to/DBData/WWL/system01.dbf
restoringdatafile 00002 to/DBData/WWL/undotbs01.dbf
restoringdatafile 00003 to/DBData/WWL/sysaux01.dbf
channelORA_DISK_1: reading frombackup piece /DBBak/bak_WWL_05_23_0enbn2bk_1_1
channelORA_DISK_1: restored backuppiece 1
piecehandle=/DBBak/bak_WWL_05_23_0enbn2bk_1_1tag=TAG20120523T133235
channelORA_DISK_1: restore complete,elapsed time: 00:01:05
Finished restoreat 23-MAY-12
RMAN>
RMAN> recover database;
Starting recoverat 23-MAY-12
using channel ORA_DISK_1
starting mediarecovery
media recovery complete,elapsedtime: 00:00:05
Finished recoverat 23-MAY-12
RMAN> alter database open; ---------我们看到数据库已经打开了处于open状态
database opened
SQL> select instance_name,statusfrom v$instance;
INSTANCE_NAME STATUS
----------------------------
WWL OPEN
SQL>
相关阅读:
探索Oracle之RMAN_01概念 http://www.linuxidc.com/Linux/2012-05/60530.htm
探索Oracle之RMAN_02基本使用 http://www.linuxidc.com/Linux/2012-05/60578.htm
探索Oracle之RMAN_03非一致性备份 http://www.linuxidc.com/Linux/2012-05/61025.htm
探索Oracle之RMAN_04非一致性备份 http://www.linuxidc.com/Linux/2012-05/61180.htm
探索Oracle之RMAN_05增量备份 http://www.linuxidc.com/Linux/2012-05/61181.htm
探索Oracle之RMAN_06备份策略 http://www.linuxidc.com/Linux/2012-05/61450.htm
探索Oracle之RMAN_07单个数据文件丢失恢复 http://www.linuxidc.com/Linux/2012-06/63524.htm
探索Oracle之RMAN_07整个业务表空间丢失恢复 http://www.linuxidc.com/Linux/2012-07/64582.htm
探索Oracle之RMAN_07 磁盘损坏数据丢失恢复 http://www.linuxidc.com/Linux/2012-07/64588.htm
探索Oracle之RMAN_07 数据库所有文件全部丢失恢复 http://www.linuxidc.com/Linux/2012-07/64587.htm
探索Oracle之RMAN_07 重做日志redu文件丢失恢复 http://www.linuxidc.com/Linux/2012-07/64586.htm
探索Oracle之RMAN_07 参数文件丢失恢复 http://www.linuxidc.com/Linux/2012-07/64585.htm
探索Oracle之RMAN_07控制文件丢失恢复 http://www.linuxidc.com/Linux/2012-07/64584.htm
探索Oracle之RMAN_07 system表空间丢失恢复 http://www.linuxidc.com/Linux/2012-07/64583.htm
