0
点赞
收藏
分享

微信扫一扫

探索ORACLE之RMAN_07 数据库所有文件全部丢失恢复


探索ORACLE之RMAN_07 数据库所有文件全部丢失恢复


 

 

 

     介于Rman恢复的自动性,我们刚才对数据库的全库,单表空间,数据文件控制文件和参数文件都做了备份,这些备份的内容是数据库运行不可缺少的必要元素,通常情况下我们在生产库中只需要备份这些内容即可。有了这些备份,即使数据库的的任何信息丢失,我们都可以得以恢复使得数据库的正常运行,当然如果我们将archivelog 也备份,当然就会更好了,一般情况下这个可以不用备份,备份archivelog占用空间非常大。如果有海量的储存,当然备份也无妨咯。

Egg:

删除数据库的所有文件,仅保留redo日志和archivelog文件


删除控制文件:

[oracle@wwldb WWL]$ pwd

/DBData/oradata/WWL

[oracle@wwldb WWL]$ ls

control02.ctl control03.ctl

[oracle@wwldb WWL]$ rm -rf *.ctl

[oracle@wwldbWWL]$

[oracle@wwldb WWL]$ pwd

/DBSoft/oradata/WWL

[oracle@wwldb WWL]$ ls

control01.ctl

[oracle@wwldb WWL]$ rm -rfcontrol01.ctl

[oracle@wwldbWWL]$


删除数据文件:

[oracle@wwldb WWL]$ ls

redo01.log redo02.log redo03.logsysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf

[oracle@wwldb WWL]$ rm -rf *.dbf

[oracle@wwldb WWL]$ ls

redo01.log redo02.log redo03.log

[oracle@wwldbWWL]$


删除参数文件:

[oracle@wwldb dbs]$ cd$ORACLE_HOME/dbs

[oracle@wwldb dbs]$ rm -rfspfileWWL.ora

[oracle@wwldbdbs]$


执行大恢复:

1、现在数据库是关闭状态

[oracle@wwldb dbs]$ ps -ef|grep ora

root 2910 2888 0 10:02 ? 00:00:15hald-addon-storage: polling/dev/hdc

root 28954 3478 0 11:38 pts/100:00:00 su - oracle

oracle 28955 28954 0 11:38 pts/100:00:00 -bash

root 29361 3438 0 13:41 pts/200:00:00 su - oracle

oracle 29362 29361 0 13:41 pts/200:00:01 -bash

oracle 29988 29362 0 16:06 pts/200:00:00sqlplus as sysdba

oracle 30102 28955 0 17:03 pts/100:00:00 ps -ef

oracle 30103 28955 0 17:03 pts/100:00:00 grep ora

[oracle@wwldbdbs]$


2、要恢复首先要将数据库启动到mount状态才能恢复

[oracle@wwldb dbs]$ sqlplus / assysdba

SQL*Plus:Release 10.2.0.1.0 -Production on Wed May 23 17:03:42 2012

Copyright (c)1982, 2005, Oracle. Allrights reserved.

Connected to anidle instance.

SQL> startup

ORA-01078:failure in processingsystem parameters

LRM-00109: couldnot open parameterfile '/DBSoft/product/10.2.0/db_1/dbs/initWWL.ora'

SQL>


3、因为数据库没有参数文件,起不来,只能能启动到nomount状态

[oracle@wwldb dbs]$ rman target /

RecoveryManager: Release 10.2.0.1.0- Production on Wed May 23 17:06:32 2012

Copyright (c)1982, 2005, Oracle. Allrights reserved.

connected totarget database (notstarted)

RMAN> startup force nomount;

startup failed:ORA-01078: failure inprocessing system parameters

LRM-00109: couldnot open parameterfile '/DBSoft/product/10.2.0/db_1/dbs/initWWL.ora'

starting Oracleinstance withoutparameter file for retrival of spfile

Oracle instancestarted

Total System GlobalArea 159383552bytes

Fixed Size 1218244 bytes

VariableSize 58722620 bytes

DatabaseBuffers 92274688 bytes

RedoBuffers 7168000 bytes

RMAN>


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://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>

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>

 

举报

相关推荐

0 条评论