基于cancel的不一致性恢复(归档存在) 第一篇
基于取消的恢复只适用于以下情况:归档日志丢失导致完全恢复失败;丢失了数据文件和未归档的重做日志(联机重做日志);
1、先关闭数据库,执行一次全库冷备份。
SQL> selectfile_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 rows selected.
SQL> shutdownimmediate
Database closed.
Database dismounted.
Oracle instance shut down.
SQL> !mkdir/DBBak2/oradata/WWL2
SQL> !cp/DBBak2/oradata/WWL/* /DBBak2/oradata/WWL2/
2、然后打开数据库继续使用,我们可以看到备份的时候数据库wwl001表中只有4条记录。
SQL> select * fromwwl001;
ID NAME
---------- ------------------
1 jetsen
2 woo
3 prudence
4 beijin
4 rows selected.
3、继续向wwl001表中插入数据,并切换日志让redo log归档。
SQL> insert intowwl001 values(5,'china');
1 row created.
SQL> insert intowwl001 values(6,'america');
1 row created.
SQL> commit;
Commit complete.
SQL> select * fromwwl001;
ID NAME
---------- ------------------
1 jetsen
2 woo
3 prudence
4 beijin
5 china
6 america
6 rows selected.
SQL>
SQL> alter systemswitch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
4、关闭数据库,模拟数据文件丢失,归档日志也丢失了,所以数据库只能做不一致性恢复。
SQL> shutdownabort;
ORACLE instance shut down.
SQL> !rm -rf/DBBak2/oradata/WWL/*.dbf
SQL> !cp/DBBak2/oradata/WWL2/*.dbf /DBBak2/oradata/WWL/
SQL> !cp /DBBak2/oradata/WWL2/*.dbf/DBBak2/oradata/WWL/
5、执行基于取消的不完全恢复
SQL> startup
ORACLE instance started.
Total System Global Area 100663296 bytes
Fixed Size 1217884 bytes
Variable Size 88083108 bytes
Database Buffers 8388608 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1:'/DBBak2/oradata/WWL/system01.dbf'
SQL>select * fromv$recover_file;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
---------- ------- --------------------------- ---------- ---------
1 ONLINE ONLINE 1783695 31-JUL-12
2 ONLINE ONLINE 1783695 31-JUL-12
3 ONLINE ONLINE 1783695 31-JUL-12
4 ONLINE ONLINE 1783695 31-JUL-12
5 ONLINE ONLINE 1783695 31-JUL-12
6 ONLINE ONLINE 1783695 31-JUL-12
7 ONLINE ONLINE 1783695 31-JUL-12
7 rows selected.
SQL> recoverdatabase until cancel;
ORA-00279: change 1783695 generated at07/31/2012 15:32:04 needed for thread 1
ORA-00289: suggestion :/DBSoft/product/10.2.0/db_1/dbs/arch/1_2_790095025.dbf
ORA-00280: change 1783695 for thread 1 isin sequence #2
Specify log: {=suggested |filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SQL>
SQL> select * fromv$recover_file;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
---------- ------- --------------------------- ---------- ---------
1 ONLINE ONLINE 1783695 31-JUL-12
2 ONLINE ONLINE 1783695 31-JUL-12
3 ONLINE ONLINE 1783695 31-JUL-12
4 ONLINE ONLINE 1783695 31-JUL-12
5 ONLINE ONLINE 1783695 31-JUL-12
6 ONLINE ONLINE 1783695 31-JUL-12
7 ONLINE ONLINE 1783695 31-JUL-12
7 rows selected.
SQL> alterdatabase open resetlogs;
Database altered.
SQL> conn wwl/wwl
Connected.
SQL> select * fromwwl001;
ID NAME
---------- ------------------
1 jetsen
2 woo
3 prudence
4 beijin
SQL>
相关阅读:
探索Oracle之RMAN_01概念
探索Oracle之RMAN_02基本使用
探索Oracle之RMAN_03非一致性备份
探索Oracle之RMAN_04非一致性备份
探索Oracle之RMAN_05增量备份
探索Oracle之RMAN_06备份策略
探索Oracle之RMAN_07单个数据文件丢失恢复
探索Oracle之RMAN_07整个业务表空间丢失恢复
探索Oracle之RMAN_07 磁盘损坏数据丢失恢复
探索Oracle之RMAN_07 数据库所有文件全部丢失恢复
探索Oracle之RMAN_07 重做日志redu文件丢失恢复
探索Oracle之RMAN_07 参数文件丢失恢复
探索Oracle之RMAN_07控制文件丢失恢复
探索Oracle之RMAN_07 system表空间丢失恢复