首页 > 代码库 > SYSTEM毁坏恢复
SYSTEM毁坏恢复
system毁坏恢复
建议做整个库的冷备(datafile+controlfile+redo log file)
(1)shutdowm
(2)拷贝文件datafile+controlfile+redo log file
(3)startup
(5)rm system01.dbf
(6)再次打开数据库,报错
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: ‘/orcl_backup/cold/system01.dbf
(7) SQL> select file#, name,CHECKPOINT_CHANGE# from v$datafile;
FILE# NAME CHECKPOINT_CHANGE#
---------- ----------------------------------- ------------------
1 /orcl_backup/cold/system01.dbf 5020712
2 /orcl_backup/cold/sysaux01.dbf 5020712
3 /orcl_backup/cold/undotbs01.dbf 5020712
4 /orcl_backup/cold/users01.dbf 5020712
5 /orcl_backup/cold/tp01.dbf 5020712
SQL> select file#, name,CHECKPOINT_CHANGE# from v$datafile_header;
FILE# NAME CHECKPOINT_CHANGE#
---------- ----------------------------------- ------------------
1 0 ====》文件已经不出在了。
2 /orcl_backup/cold/sysaux01.dbf 5020712
3 /orcl_backup/cold/undotbs01.dbf 5020712
4 /orcl_backup/cold/users01.dbf 5020712
5 /orcl_backup/cold/tp01.dbf 5020712
CHECKPOINT_COUNT ====>计数器,数据文件和控制文件头。
(8)拷贝备份的system01到目标文件夹
cp system01.dbf /orcl_backup/cold/system01.dbf
(9)查看v$datafile_header;
SQL> select file#, name,CHECKPOINT_CHANGE# from v$datafile_header;
FILE# NAME CHECKPOINT_CHANGE#
---------- ----------------------------------- ------------------
1 /orcl_backup/cold/system01.dbf 5019954
2 /orcl_backup/cold/sysaux01.dbf 5020712
3 /orcl_backup/cold/undotbs01.dbf 5020712
4 /orcl_backup/cold/users01.dbf 5020712
5 /orcl_backup/cold/tp01.dbf 5020712
发现现在的 5019954与其他的检查点不同。
SQL> select file#, name,CHECKPOINT_CHANGE# from v$datafile;
FILE# NAME CHECKPOINT_CHANGE#
---------- ----------------------------------- ------------------
1 /orcl_backup/cold/system01.dbf 5020712
2 /orcl_backup/cold/sysaux01.dbf 5020712
3 /orcl_backup/cold/undotbs01.dbf 5020712
4 /orcl_backup/cold/users01.dbf 5020712
5 /orcl_backup/cold/tp01.dbf 5020712
这样的原因:当buffer cache 中的数据完成写入文件上那一刻的时间。把scn写到文件头上,同时信息会拷贝到控制文件。
此时文件就是比较旧
(10)SQL> recover datafile 1;
ORA-00279: change 5019954 generated at 12/29/2014 23:06:33 needed for thread 1
ORA-00289: suggestion : /app/oracle/archive_log/1_327_861876939.dbf
ORA-00280: change 5019954 for thread 1 is in sequence #327
说明:
QL> select file#, name,CHECKPOINT_CHANGE# from v$datafile_header;
FILE# NAME CHECKPOINT_CHANGE#
---------- ----------------------------------- ------------------
1 /orcl_backup/cold/system01.dbf 5019954
2 /orcl_backup/cold/sysaux01.dbf 5020712
3 /orcl_backup/cold/undotbs01.dbf 5020712
4 /orcl_backup/cold/users01.dbf 5020712
5 /orcl_backup/cold/tp01.dbf 5020712
当 recover datafile 1去扫描1号文件,偏移量为484的地方。找到检查点
找到/app/oracle/archive_log/1_327_861876939.dbf的日志,从数据文件数文件头一号块上的500偏移量的RBA 的中读到的RBA的位置开始恢复。
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
说明 RET回车,应用归档日志
filename:自己想要的归档日志
AUTO:自动应有所有的归档
CANEL:不完全恢复
(11)回车
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00279: change 5020630 generated at 12/29/2014 23:34:05 needed for thread 1
ORA-00289: suggestion : /app/oracle/archive_log/1_328_861876939.dbf
ORA-00280: change 5020630 for thread 1 is in sequence #328
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00279: change 5020633 generated at 12/29/2014 23:34:07 needed for thread 1
ORA-00289: suggestion : /app/oracle/archive_log/1_329_861876939.dbf
ORA-00280: change 5020633 for thread 1 is in sequence #329
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00279: change 5020636 generated at 12/29/2014 23:34:08 needed for thread 1
ORA-00289: suggestion : /app/oracle/archive_log/1_330_861876939.dbf
ORA-00280: change 5020636 for thread 1 is in sequence #330
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
Log applied.
Media recovery complete. =======》到这里完成
(12)查看v$log,只恢复到330.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
1 1 331 52428800 512 1 YES INACTIVE 5020639 29-DEC-14 5020642 29-DEC-14
3 1 333 52428800 512 1 NO CURRENT 5020645 29-DEC-14 2.8147E+14
2 1 332 52428800 512 1 YES INACTIVE 5020642 29-DEC-14 5020645 29-DEC-14
在查看 告警日志
ORA-279 signalled during: ALTER DATABASE RECOVER CONTINUE DEFAULT ...
Tue Dec 30 01:43:52 2014
ALTER DATABASE RECOVER CONTINUE DEFAULT
Media Recovery Log /app/oracle/archive_log/1_329_861876939.dbf
ORA-279 signalled during: ALTER DATABASE RECOVER CONTINUE DEFAULT ...
ALTER DATABASE RECOVER CONTINUE DEFAULT
Media Recovery Log /app/oracle/archive_log/1_330_861876939.dbf
Recovery of Online Redo Log: Thread 1 Group 1 Seq 331 Reading mem 0
Mem# 0: /orcl_backup/cold/redo01.log
Recovery of Online Redo Log: Thread 1 Group 2 Seq 332 Reading mem 0
Mem# 0: /orcl_backup/cold/redo02.log
Recovery of Online Redo Log: Thread 1 Group 3 Seq 333 Reading mem 0
Mem# 0: /orcl_backup/cold/redo03.log
它使用redo log进行恢复
alter database open;时,
oracle进行了实例恢复
alter database open
Beginning crash recovery of 1 threads
parallel recovery started with 2 processes
在重做一遍的redo log:
Thread 1 opened at log sequence 334
Current log# 1 seq# 334 mem# 0: /orcl_backup/cold/redo01.log
Successful open of redo thread 1
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Tue Dec 30 01:48:29 2014
因为,这个是正在这个日志上,没有被归档。
SYSTEM毁坏恢复