1.7 恢复方法二,离线恢复
开始执行恢复操作,分为五个步骤:
1、强制将数据库启动到mount状态
SQL> startupforce mount;
Oracle instancestarted.
Total SystemGlobal Area 285212672 bytes
Fixed Size 1218968 bytes
VariableSize 96470632 bytes
DatabaseBuffers 180355072 bytes
RedoBuffers 7168000 bytes
Databasemounted.
2、将数据文件从备份中restore出来
RMAN> restoredatafile '/DBData/WWL/wwl002.dbf'
2> ;
Starting restoreat 22-JUN-12
using targetdatabase control file instead of recovery catalog
allocatedchannel: ORA_DISK_1
channelORA_DISK_1: sid=156 devtype=DISK
channelORA_DISK_1: starting datafile backupset restore
channelORA_DISK_1: specifying datafile(s) to restore from backup set
restoringdatafile 00006 to /DBData/WWL/wwl002.dbf
channelORA_DISK_1: reading from backup piece /DBBak/bak_WWL_06_22_0vne4ph6_1_1
channelORA_DISK_1: restored backup piece 1
piecehandle=/DBBak/bak_WWL_06_22_0vne4ph6_1_1 tag=TAG20120622T010021
channelORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restoreat 22-JUN-12
3、执行数据恢复,保证scn一致
RMAN> recover datafile '/DBData/WWL/wwl002.dbf';
Starting recover at 22-JUN-12
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:02
Finished recover at 22-JUN-12
RMAN>
4、开启数据库
SQL> conn /as sysdba
Connected.
SQL> alterdatabase open;
Databasealtered.
5、验证数据是否恢复
SQL> select *from tab;
TNAME TABTYPE CLUSTERID
------------------------------------- ----------
WWL01 TABLE
WWL02 TABLE
WWL03 TABLE
WWL04 TABLE
WWL05 TABLE
SQL> selectcount(*) from wwl01;
COUNT(*)
----------
5
SQL>
2、 整个业务表空间丢失恢复
注意:以下的所有实验,都是基于上面的全库备份来做的恢复。
2.1 删除wwl表空间的所有数据文件
[root@wwldb ~]# cd /DBData/WWL/
[root@wwldb WWL]# rm -rf wwl*
[root@wwldb WWL]# ll
总计 881068
-rw-r----- 1 oracle oinstall 31457792 06-22 01:34 redo01.log
-rw-r----- 1 oracle oinstall 31457792 06-22 01:34 redo02.log
-rw-r----- 1 oracle oinstall 31457792 06-22 02:14 redo03.log
-rw-r----- 1 oracle oinstall 27263795206-22 02:08 sysaux01.dbf
-rw-r----- 1 oracle oinstall 50332467206-22 02:09 system01.dbf
-rw-r----- 1 oracle oinstall 20979712 05-29 22:00 temp01.dbf
-rw-r----- 1 oracle oinstall 26222592 06-22 02:08 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 06-22 01:34 users01.dbf
2.2 启动数据库,报如下错误。
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218968 bytes
Variable Size 100664936 bytes
Database Buffers 176160768 bytes
Redo Buffers 7168000 bytes
Database mounted.
ORA-01157: cannot identify/lockdata file 5 - see DBWR trace file
ORA-01110: data file 5:'/DBData/WWL/wwl001.dbf'
2.3 检查跟踪文件,非常清晰的告诉丢失了有文件找不到,丢失了。
*** SERVICE NAME:() 2012-06-22 09:17:38.573
*** SESSION ID:(167.1) 2012-06-22 09:17:38.573
ORA-01157: Message 1157 not found; No message file forproduct=RDBMS, facility=ORA; arguments: [5]
ORA-01110: Message 1110 not found; No message file forproduct=RDBMS, facility=ORA; arguments: [5] [/DBData/WWL/wwl001.dbf]
ORA-27037: Message 27037 not found; No message file forproduct=RDBMS, facility=ORA
Linux Error: 2: No such file or directory
Additional information: 3
ORA-01157: Message 1157 not found; No message file for product=RDBMS,facility=ORA; arguments: [6]
ORA-01110: Message 1110 not found; No message file forproduct=RDBMS, facility=ORA; arguments: [6] [/DBData/WWL/wwl002.dbf]
ORA-27037: Message 27037 not found; No message file forproduct=RDBMS, facility=ORA
Linux Error: 2: No such file or directory
Additional information: 3
ORA-01157: Message 1157 not found; No message file forproduct=RDBMS, facility=ORA; arguments: [7]
ORA-01110: Message 1110 not found; No message file forproduct=RDBMS, facility=ORA; arguments: [7] [/DBData/WWL/wwl003.dbf]
ORA-27037: Message 27037 not found; No message file forproduct=RDBMS, facility=ORA
Linux Error: 2: No such file or directory
Additional information: 3
由如上的跟踪信息我们得出是由于/DBData/WWL/wwl001.dbf;/DBData/WWL/wwl002.dbf;/DBData/WWL/wwl001.dbf这三个文件丢失导致数据库无法起来,并且这三个文件同时构成了一个WWL表空间。在这个表空间中存储了各种各样重要的数据。同样我们可以按照之前的方法通过恢复数据文件的方式来进行数据恢复,介于这次丢失的是所有数据文件,数量比较多,而且如果对所有数据文件做恢复,不仅大量的增加的工作量,同时也增加的恢复的风险。所以在这里我们通过使用RMAN执行表空间恢复的方式来进行恢复。当然基于表空间的恢复也分两种,一直是在不影响数据库其它业务情况下的在线联机恢复,还有一种是停机停业务的恢复,详细见如下:
