探索ORACLE之RMAN_07单个数据文件丢失恢复(二)
nstancestarted
databasemounted
Total System GlobalArea 285212672 bytes
Fixed Size 1218968 bytes
VariableSize 92276328 bytes
DatabaseBuffers 184549376 bytes
RedoBuffers 7168000 bytes
www.2cto.com
2、将对应的数据文件offline
SQL> alter database datafile '/DBData/WWL/wwl001.dbf' offline;
Database altered.
3、开启数据库
SQL> alter database open;
Database altered.
4、将数据文件从备份中restore出来
RMAN> restore datafile'/DBData/WWL/wwl001.dbf';
Starting restore at 22-JUN-12
using target database control fileinstead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141devtype=DISK
channel ORA_DISK_1: startingdatafile backupset restore
channel ORA_DISK_1: specifyingdatafile(s) to restore from backup set
restoring datafile 00005 to /DBData/WWL/wwl001.dbf
channel ORA_DISK_1: reading frombackup piece /DBBak/bak_WWL_06_22_0vne4ph6_1_1
channel ORA_DISK_1: restored backuppiece 1
piecehandle=/DBBak/bak_WWL_06_22_0vne4ph6_1_1 tag=TAG20120622T010021
channel ORA_DISK_1: restorecomplete, elapsed time: 00:00:07
Finished restore at 22-JUN-12
查看到数据文件已经restore出来了。
[oracle@wwldb WWL]$ ll wwl*
-rw-r----- 1 oracle oinstall52436992 Jun 22 01:21 wwl001.dbf
-rw-r----- 1 oracle oinstall 5251072 Jun 22 01:20 wwl002.dbf
-rw-r----- 1 oracle oinstall 5251072 Jun 22 01:20 wwl003.dbf
www.2cto.com
5、执行数据恢复,保证scn一致
RMAN>recover datafile '/DBData/WWL/wwl001.dbf';
Startingrecover at 22-JUN-12
using targetdatabase control file instead of recovery catalog
allocatedchannel: ORA_DISK_1
channelORA_DISK_1: sid=144 devtype=DISK
starting mediarecovery
media recoverycomplete, elapsed time: 00:00:01
Finishedrecover at 22-JUN-12
RMAN>
6、将数据文件在线
SQL> conn / as sysdba
Connected.
SQL> alter database datafile'/DBData/WWL/wwl001.dbf' online;
Database altered.
7、验证数据是否恢复,可以看到数据全部恢复回来了。
SQL>conn wwl/wwl
Connected.
SQL>select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------------- ----------
WWL01 TABLE
WWL02 TABLE
WWL03 TABLE
WWL04 TABLE
WWL05 TABLE
SQL>select count(*) from tab;
www.2cto.com
COUNT(*)
----------
5
SQL>
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> ; www.2cto.com
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: restore