179.You have lost datafiles 1 and 3 from your database, and the database has crashed. In what order
should you perform the following steps to recover your database?
1. Take the datafiles that were lost offline.
2. startup mount the database
3. Issue the alter database open command.
4. Restore the datafiles that were lost
5. Recover the datafiles with the recover datafile command.
6. Bring the datafiles back online.
7. Recover the database with the recover database command.
A. 2, 1, 3, 4, 5, 6
B. 2, 4, 5, 3
C. 4, 7, 3
D. 2, 4, 7, 3
E. 2, 7, 3
Answer: B
答案解析:
参考:http://blog.csdn.net/rlhua/article/details/12346829
一般的数据文件恢复,offline--restore--recover--online
关键的数据文件,如system,undo等,shutdown-startup mount---restore--recover--alter database open
文件中的1和3文件是system和undo关键性数据文件,故用第二种方法。
实验验证:
首先查看数据文件:
sys@TEST1107> select file_id,file_name from dba_data_files;
FILE_ID FILE_NAME
---------- --------------------------------------------------
4 /u01/app/oracle/oradata/test1107/users01.dbf
3 /u01/app/oracle/oradata/test1107/undotbs01.dbf
2 /u01/app/oracle/oradata/test1107/sysaux01.dbf
1 /u01/app/oracle/oradata/test1107/system01.dbf
5 /u01/app/oracle/oradata/test1107/example01.dbf
6 /u01/app/oracle/oradata/test1107/test01.dbf
6 rows selected.
OS删除数据文件1和3
[oracle@rtest ~]$ rm -f /u01/app/oracle/oradata/test1107/system01.dbf
[oracle@rtest ~]$ rm -f /u01/app/oracle/oradata/test1107/undotbs01.dbf
关库,再起库,报错,关库,在起到mount状态
sys@TEST1107> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
sys@TEST1107> startup
ORACLE instance started.
Total System Global Area 1269366784 bytes
Fixed Size 2227984 bytes
Variable Size 872415472 bytes
Database Buffers 385875968 bytes
Redo Buffers 8847360 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/app/oracle/oradata/test1107/system01.dbf'
sys@TEST1107> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
sys@TEST1107> startup mount;
ORACLE instance started.
Total System Global Area 1269366784 bytes
Fixed Size 2227984 bytes
Variable Size 872415472 bytes
Database Buffers 385875968 bytes
Redo Buffers 8847360 bytes
Database mounted.
使用rman进行restore和recover,然后打开数据库。
[oracle@rtest ~]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Thu Nov 7 13:28:23 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST1107 (DBID=2336818266, not open)
RMAN> restore datafile 1,3
2> ;
Starting restore at 07-NOV-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=189 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=221 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=3 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/test1107/undotbs01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/TEST1107/backupset/2013_11_07/o1_mf_nnndf_TAG20131107T131035_97qox15d_.bkp
channel ORA_DISK_2: starting datafile backup set restore
channel ORA_DISK_2: specifying datafile(s) to restore from backup set
channel ORA_DISK_2: restoring datafile 00001 to /u01/app/oracle/oradata/test1107/system01.dbf
channel ORA_DISK_2: reading from backup piece /u01/app/oracle/fast_recovery_area/TEST1107/backupset/2013_11_07/o1_mf_nnndf_TAG20131107T131035_97qowz79_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/TEST1107/backupset/2013_11_07/o1_mf_nnndf_TAG20131107T131035_97qox15d_.bkp tag=TAG20131107T131035
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:26
channel ORA_DISK_2: piece handle=/u01/app/oracle/fast_recovery_area/TEST1107/backupset/2013_11_07/o1_mf_nnndf_TAG20131107T131035_97qowz79_.bkp tag=TAG20131107T131035
channel ORA_DISK_2: restored backup piece 1
channel ORA_DISK_2: restore complete, elapsed time: 00:02:56
Finished restore at 07-NOV-13
RMAN> recover datafile 1,3;
Starting recover at 07-NOV-13
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 07-NOV-13
RMAN> alter database open;
database opened