探索Oracle不完全恢复之--基于备份控制文件恢复
基于备份控制文件(unsing backup controlfile)的恢复
主要适用于:基于备份控制文件的恢复只要适用于以下情况:表空间被意外删除;所有控制文件全部损坏。
1、关闭数据库执行一次全库冷备份:
SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
/DBBak2/oradata/WWL/users01.dbf
/DBBak2/oradata/WWL/sysaux01.dbf
/DBBak2/oradata/WWL/undotbs01.dbf
/DBBak2/oradata/WWL/system01.dbf
/DBBak2/oradata/WWL/WWL001.dbf
/DBBak2/oradata/WWL/WWL002.dbf
/DBBak2/oradata/WWL/WWL003.dbf
7 rowsselected.
SQL> shutdown immediate
Databaseclosed.
Databasedismounted.
Oracleinstance shut down.
SQL> !mkdir /DBBak2/oradata/WWL2
SQL> !cp /DBBak2/oradata/WWL/* /DBBak2/oradata/WWL2/
通过如上的操作数据库现在已经有了一个冷备份了,里面包含另外wwl表空间,现在模拟用户误删除了wwl表空间。
SQL> startup
ORACLEinstance started.
TotalSystem Global Area 100663296 bytes
FixedSize 1217884 bytes
VariableSize 88083108 bytes
DatabaseBuffers 8388608 bytes
RedoBuffers 2973696 bytes
Databasemounted.
Databaseopened.
SQL>
模拟删除表空间
SQL> drop tablespace wwl including contents;
Tablespacedropped.
当前的控制文件中已经不包含wwl表空间了,但是我们之前冷备份的控制文件中还是包含的,所以必须使用以前的控制文件来进行wwl表空间的恢复。
还原之前备份的数据文件:
SQL> shutdown immediate
Databaseclosed.
Databasedismounted.
ORACLEinstance shut down.
SQL> !rm -rf /DBBak2/oradata/WWL/*.dbf
SQL> !rm -rf /DBBak2/oradata/WWL/*.ctl
SQL> !cp /DBBak2/oradata/WWL2/*.dbf /DBBak2/oradata/WWL/
SQL> !cp /DBBak2/oradata/WWL2/*.ctl /DBBak2/oradata/WWL/
SQL>
使用控制文件进行恢复:
SQL> startup
ORACLEinstance started.
TotalSystem Global Area 100663296 bytes
FixedSize 1217884 bytes
VariableSize 88083108 bytes
DatabaseBuffers 8388608 bytes
RedoBuffers 2973696 bytes
Databasemounted.
ORA-00338:log 5 of thread 1 is more recent than control file
ORA-00312:online log 5 thread 1: '/DBBak2/oradata/WWL/redo5a.log'
ORA-00312:online log 5 thread 1: '/DBBak2/oradata/WWL/redo5b.log'
SQL> recover database using backup controlfile until cancel;
ORA-00279:change 1782560 generated at 07/31/2012 14:37:24 needed for thread 1
ORA-00289:suggestion : /DBSoft/product/10.2.0/db_1/dbs/arch/1_3_790085314.dbf
ORA-00280:change 1782560 for thread 1 is in sequence #3
Specifylog: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Mediarecovery cancelled.
SQL> alter database open resetlogs;
Databasealtered.
SQL>
至此已经恢复成功。
相关阅读: