恢復(fù)原理:
1.冷備份的數(shù)據(jù)文件*.dbf比現(xiàn)在要舊,那么數(shù)據(jù)文件的scn肯定就比現(xiàn)在的??;
2.使用日志挖掘方法,在日志中找出刪表時(shí)的scn或時(shí)間戳;
3.在數(shù)據(jù)庫shutdown的狀態(tài)下,用冷備份的數(shù)據(jù)文件*.dbf,覆蓋現(xiàn)在的*.dbf文件;保證數(shù)據(jù)文件完整性;
4.啟動(dòng)數(shù)據(jù)庫到mount下,恢復(fù)到日志挖掘的SCN或時(shí)間點(diǎn)(利用日志對(duì)數(shù)據(jù)文件重做一次)
5.以
resetlogs方式打開數(shù)據(jù)庫,以前的日志就被覆蓋了;
示例二:當(dāng)前日志組損壞,造成數(shù)據(jù)庫崩潰
環(huán)境:
(1)提前對(duì)數(shù)據(jù)庫做一次全庫冷備份;
(2)在seiang用戶下有一張test1表隸屬于seiang表空間;
示例三:歸檔日志丟失或損壞
環(huán)境:
(1)提前有一套完成的數(shù)據(jù)文件的冷備份;
(2)在seiang用戶下有一張test1表隸屬于seiang表空間;
-
SYS@seiang11g>select owner,table_name,tablespace_name from dba_tables where owner='SEIANG';
-
-
OWNER TABLE_NAME TABLESPACE_NAME
-
------------------------------ ------------------------------ ------------------------------
-
SEIANG TEST1 SEIANG
-
SEIANG TEST2 WJQ
-
SEIANG TEST3 WJQBEST
-
-
SYS@seiang11g>select * from seiang.test1;
-
-
ID NAME AGE
-
---------- ------------------------------ ----------
-
1 wjq 23
-
2 seiang 24
-
3 wjqdood 25
-
4 wjqbest 30
-
-
--查看當(dāng)前日志序號(hào)為2
-
SYS@seiang11g>select group#,sequence#,status from v$log;
-
-
GROUP# SEQUENCE# STATUS
-
---------- ---------- ----------------
-
1 1 INACTIVE
-
2 2 CURRENT
-
3 0 UNUSED
-
-
-
--修改數(shù)據(jù)并提交(sequence號(hào)2)
-
SYS@seiang11g>update seiang.test1 set age=100 where id=1;
-
1 row updated.
-
-
SYS@seiang11g>commit;
-
Commit complete.
-
-
SYS@seiang11g>alter system switch logfile;
-
System altered.
-
-
--修改數(shù)據(jù)并提交(sequence號(hào)3)
-
SYS@seiang11g>update seiang.test1 set age=200 where id=1;
-
1 row updated.
-
-
SYS@seiang11g>commit;
-
Commit complete.
-
-
SYS@seiang11g>alter system switch logfile;
-
System altered.
-
-
--修改數(shù)據(jù)并提交(sequence號(hào)4)
-
SYS@seiang11g>update seiang.test1 set age=300 where id=1;
-
1 row updated.
-
-
SYS@seiang11g>commit;
-
Commit complete.
-
-
SYS@seiang11g>alter system switch logfile;
-
System altered.
-
-
--修改數(shù)據(jù)并提交(sequence號(hào)5)
-
SYS@seiang11g>update seiang.test1 set age=400 where id=1;
-
1 row updated.
-
-
SYS@seiang11g>commit;
-
Commit complete.
-
-
SYS@seiang11g>alter system switch logfile;
-
System altered.
-
-
--修改數(shù)據(jù)并提交(sequence號(hào)6)
-
SYS@seiang11g>update seiang.test1 set age=500 where id=1;
-
1 row updated.
-
-
SYS@seiang11g>commit;
-
Commit complete.
-
-
SYS@seiang11g>alter system switch logfile;
-
System altered.
-
-
--修改數(shù)據(jù)并提交(sequence號(hào)7)
-
SYS@seiang11g>update seiang.test1 set age=600 where id=1;
-
1 row updated.
-
-
SYS@seiang11g>commit;
-
Commit complete.
-
-
SYS@seiang11g>alter system switch logfile;
-
System altered.
-
-
--當(dāng)前聯(lián)機(jī)日志序號(hào)為8
-
SYS@seiang11g>select group#,sequence#,status from v$log;
-
-
GROUP# SEQUENCE# STATUS
-
---------- ---------- ----------------
-
1 7 ACTIVE
-
2 8 CURRENT
-
3 6 ACTIVE
-
-
--查看相應(yīng)的歸檔日志
-
SYS@seiang11g>select name from v$archived_log;
-
-
NAME
-
------------------------------------------------------
-
/u01/app/oracle/arch/arch_1_950962051_1.log
-
/u01/app/oracle/arch/arch_1_950962051_2.log
-
/u01/app/oracle/arch/arch_1_950971495_1.log
-
/u01/app/oracle/arch/arch_1_950971495_2.log
-
/u01/app/oracle/arch/arch_1_950972396_1.log
-
/u01/app/oracle/arch/arch_1_950972396_2.log
-
/u01/app/oracle/arch/arch_1_950972396_3.log
-
/u01/app/oracle/arch/arch_1_950972396_4.log
-
/u01/app/oracle/arch/arch_1_950972396_5.log
-
/u01/app/oracle/arch/arch_1_950972396_6.log
-
/u01/app/oracle/arch/arch_1_950972396_7.log
-
-
--關(guān)閉數(shù)據(jù)庫
-
SYS@seiang11g >shutdown immediate
-
Database closed.
-
Database dismounted.
-
ORACLE instance shut down.
-
-
--模擬數(shù)據(jù)文件seiang損壞
-
SYS@seiang11g>host rm /u01/app/oracle/oradata/OraDB11g/seiang01.dbf
-
-
-
--重新打開數(shù)據(jù)庫 ,由于數(shù)據(jù)文件的丟死,數(shù)據(jù)庫無法open
-
SYS@seiang11g>startup
-
ORACLE instance started.
-
-
Total System Global Area 1252663296 bytes
-
Fixed Size 2252824 bytes
-
Variable Size 788533224 bytes
-
Database Buffers 452984832 bytes
-
Redo Buffers 8892416 bytes
-
Database mounted.
-
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
-
ORA-01110: data file 7: '/u01/app/oracle/oradata/OraDB11g/seiang01.dbf'
-
-
-
SYS@seiang11g>select * from v$recover_file;
-
-
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
-
---------- ------- ------- ----------------------------------------------------------------- ---------- ---------
-
7 ONLINE ONLINE FILE NOT FOUND 0
-
-
--還原備份的數(shù)據(jù)文件
-
SYS@seiang11g>host cp /u01/app/oracle/UMAN_Backup/seiang01.dbf /u01/app/oracle/oradata/OraDB11g/
-
-
SYS@seiang11g>select * from v$recover_file;
-
-
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
-
---------- ------- ------- ----------------------------------------------------------------- ---------- ---------
-
7 ONLINE ONLINE UNKNOWN ERROR 1913765 02-AUG-17
-
-
-
--查看一下歸檔日志的詳細(xì)信息
-
SYS@seiang11g>select sequence#, name, first_change#, next_change# from v$archived_log;
-
-
SEQUENCE# NAME FIRST_CHANGE# NEXT_CHANGE#
-
---------- -------------------------------------------------- ------------- ------------
-
1 /u01/app/oracle/arch/arch_1_950962051_1.log 1914744 1921854
-
2 /u01/app/oracle/arch/arch_1_950962051_2.log 1921854 1921883
-
1 /u01/app/oracle/arch/arch_1_950971495_1.log 1913766 1914386
-
2 /u01/app/oracle/arch/arch_1_950971495_2.log 1914386 1914401
-
1 /u01/app/oracle/arch/arch_1_950972396_1.log 1914402 1936446
-
2 /u01/app/oracle/arch/arch_1_950972396_2.log 1936446 1937042
-
3 /u01/app/oracle/arch/arch_1_950972396_3.log 1937042 1937100
-
4 /u01/app/oracle/arch/arch_1_950972396_4.log 1937100 1937110
-
5 /u01/app/oracle/arch/arch_1_950972396_5.log 1937110 1937123
-
6 /u01/app/oracle/arch/arch_1_950972396_6.log 1937123 1937139
-
7 /u01/app/oracle/arch/arch_1_950972396_7.log 1937139 1937148
-
-
-
--模擬歸檔日志5丟失或者損壞
-
SYS@seiang11g>host rm /u01/app/oracle/arch/arch_1_950972396_5.log
-
-
[oracle@seiang11g OraDB11g]$ ll /u01/app/oracle/arch/arch_1_950972396_5.log
-
ls: cannot access /u01/app/oracle/arch/arch_1_950972396_5.log: No such file or directory
-
-
-
--執(zhí)行恢復(fù)操作,當(dāng)在需要?dú)w檔日志5的時(shí)候出現(xiàn)錯(cuò)誤
-
SYS@seiang11g>recover datafile 7;
-
ORA-00279: change 1913766 generated at 08/02/2017 11:12:22 needed for thread 1
-
ORA-00289: suggestion : /u01/app/oracle/arch/arch_1_950971495_1.log
-
ORA-00280: change 1913766 for thread 1 is in sequence #1
-
-
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
-
auto
-
ORA-00279: change 1914386 generated at 08/02/2017 14:48:59 needed for thread 1
-
ORA-00289: suggestion : /u01/app/oracle/arch/arch_1_950971495_2.log
-
ORA-00280: change 1914386 for thread 1 is in sequence #2
-
-
ORA-00279: change 1914402 generated at 08/02/2017 14:59:56 needed for thread 1
-
ORA-00289: suggestion : /u01/app/oracle/arch/arch_1_950972396_1.log
-
ORA-00280: change 1914402 for thread 1 is in sequence #1
-
-
ORA-00279: change 1936446 generated at 08/02/2017 15:39:52 needed for thread 1
-
ORA-00289: suggestion : /u01/app/oracle/arch/arch_1_950972396_2.log
-
ORA-00280: change 1936446 for thread 1 is in sequence #2
-
-
ORA-00279: change 1937042 generated at 08/02/2017 15:49:42 needed for thread 1
-
ORA-00289: suggestion : /u01/app/oracle/arch/arch_1_950972396_3.log
-
ORA-00280: change 1937042 for thread 1 is in sequence #3
-
-
ORA-00279: change 1937100 generated at 08/02/2017 15:51:34 needed for thread 1
-
ORA-00289: suggestion : /u01/app/oracle/arch/arch_1_950972396_4.log
-
ORA-00280: change 1937100 for thread 1 is in sequence #4
-
-
ORA-00279: change 1937110 generated at 08/02/2017 15:51:54 needed for thread 1
-
ORA-00289: suggestion : /u01/app/oracle/arch/arch_1_950972396_5.log
-
ORA-00280: change 1937110 for thread 1 is in sequence #5
-
-
ORA-00308: cannot open archived log '/u01/app/oracle/arch/arch_1_950972396_5.log'
-
ORA-27037: unable to obtain file status
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 3
-
-
--查看數(shù)據(jù)文件頭,發(fā)現(xiàn)檢查點(diǎn)不一致
-
SYS@seiang11g>select file#,name,checkpoint_change# from v$datafile_header;
-
-
FILE# NAME CHECKPOINT_CHANGE#
-
---------- -------------------------------------------------- ------------------
-
1 /u01/app/oracle/oradata/OraDB11g/system01.dbf 1937617
-
2 /u01/app/oracle/oradata/OraDB11g/sysaux01.dbf 1937617
-
3 /u01/app/oracle/oradata/OraDB11g/undotbs01.dbf 1937617
-
4 /u01/app/oracle/oradata/OraDB11g/users01.dbf 1937617
-
5 /u01/app/oracle/oradata/OraDB11g/example01.dbf 1937617
-
6 /u01/app/oracle/oradata/OraDB11g/rman01.dbf 1937617
-
7 /u01/app/oracle/oradata/OraDB11g/seiang01.dbf 1937110
-
8 /u01/app/oracle/oradata/OraDB11g/wjq01.dbf 1937617
-
9 /u01/app/oracle/oradata/OraDB11g/wjqbest01.dbf 1937617
相關(guān)連接:
Oracle手工完全恢復(fù)案例:http://blog.itpub.net/31015730/viewspace-2142669/
作者:SEian.G(苦練七十二變,笑對(duì)八十一難)
ITPUB:http://blog.itpub.net/31015730/
51CTO:http://seiang.blog.51cto.com/
向AI問一下細(xì)節(jié)