热备份system表空间
SQL> alter tablespace system beginbackup;
Tablespace altered.
SQL> !cp /u01/tiger/oradata/orcl2/system01.dbf/bk
SQL> alter tablespace system end backup;
Tablespace altered
然后做一些交易
再毁掉system表空间的文件
切换日志的时候会出错
SQL> !cp /etc/passwd/u01/tiger/oradata/orcl2/system01.dbf
SQL> alter system switch logfile;
alter system switch logfile
*
ERROR at line 1:
ORA-03113: end-of-file on communicationchannel
我们重新连接数据库
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
Oracle instance started.
Total System Global Area 314572800 bytes
Fixed Size 1219136 bytes
Variable Size 121636288 bytes
Database Buffers 184549376 bytes
Redo Buffers 7168000 bytes
Database mounted.
ORA-01122: database file 1 failedverification check
ORA-01110: data file 1:'/u01/tiger/oradata/orcl2/system01.dbf'
ORA-01251: Unknown File HeaderVersion read for file number 1
查询需要恢复的文件
SQL> select * from v$recover_file;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
---------- ------- --------------------------- ---------- ---------
1 ONLINE ONLINE WRONG FILE TYPE 0
得知1号文件需要恢复
查看恢复所需要的归档
SQL> select * from v$recovery_log;
no rows selected
这时候看见没有需要的归档日志
这时候把之前备份的是system01.dbf文件拷贝过来
SQL> !cp /bk/system01.dbf/u01/tiger/oradata/orcl2/system01.dbf
重新查看没有恢复的文件了,
SQL> select * from v$recover_file;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
---------- ------- --------------------------- ---------- ---------
1 ONLINE ONLINE 540503 06-SEP-12
看一下恢复的归档文件
SQL> select * from v$recovery_log;
THREAD# SEQUENCE# TIME
---------- ---------- ---------
ARCHIVE_NAME
------------------------------------------------------------------------------------------------------------------------
1 1 06-SEP-12
/u01/tiger/flash_recovery_area/ORCL2/archivelog/2012_09_06/o1_mf_1_1_84jo2spj_.arc
1 2 06-SEP-12
/u01/tiger/flash_recovery_area/ORCL2/archivelog/2012_09_06/o1_mf_1_2_84jo2vxd_.arc
1 3 06-SEP-12
/u01/tiger/flash_recovery_area/ORCL2/archivelog/2012_09_06/o1_mf_1_3_84jo366c_.arc
SQL> recover datafile 1; 恢复数据文件1号文件
ORA-00279: change 540503 generated at09/06/2012 14:31:27 needed for thread 1
ORA-00289: suggestion :/u01/tiger/flash_recovery_area/ORCL2/archivelog/2012_09_06/o1_mf_1_1_%u_.arc
ORA-00280: change 540503 for thread 1 is insequence #1
Specify log: {=suggested |filename | AUTO | CANCEL}
=suggested 回车系统自己去查找
filename 手动指明写日志或归档的文件位置
AUTO 系统自动去查找
cancel 取消恢复
auto
alter database open