Oracle手工不完全恢復(一):使用當前控制檔案
實驗環境
作業系統:CentOS 7.1
資料庫:Oracle 11.2.0.4
目錄
示例一:基於SCN或時間點的恢復----恢復過去某個時間誤刪除的表
示例二:當前日誌組損壞,造成資料庫崩潰
示例三:歸檔日誌丟失或損壞
示例一:基於SCN或時間點的恢復----恢復過去某個時間誤刪除的表
環境:
(1)提前對資料庫做一次全庫冷備份;
(2)在seiang使用者下有一張test1表隸屬於seiang表空間;
定位錯誤操作發生的時間或SCN:logminer
-
- SYS@seiang11g>select owner,table_name,tablespace_name from dba_tables
-
2 where owner = 'SEIANG';
-
-
OWNER TABLE_NAME TABLESPACE_NAME
-
------------------------------ ------------------------------ ------------------------------
-
SEIANG TEST1 SEIANG
-
SEIANG TEST2 WJQ
-
SEIANG TEST3 WJQBEST
-
-
--檢視test1表中資料的內容
-
SYS@seiang11g>select * from seiang.test1;
-
-
ID NAME AGE
-
---------- ------------------------------------------------------------ ----------
-
1 wjq 23
-
2 seiang 24
-
-
--檢視當前日誌序號為52
-
SYS@seiang11g>select group#,sequence#,status from v$log;
-
-
GROUP# SEQUENCE# STATUS
-
---------- ---------- ----------------
-
1 52 CURRENT
-
2 50 INACTIVE
-
3 51 INACTIVE
-
-
--誤刪除表test1表,同時purge
-
SYS@seiang11g>set time on
-
11:32:47 SYS@seiang11g>drop table seiang.test1 purge;
-
Table dropped.
-
-
11:34:49 SYS@seiang11g>commit;
-
Commit complete.
-
-
--進行兩次日誌切換
-
11:37:31 SYS@seiang11g>alter system switch logfile;
-
System altered.
-
-
11:37:51 SYS@seiang11g>/
-
System altered.
-
-
--檢視當前日誌序號為54
-
11:38:00 SYS@seiang11g>select group#,sequence#,status from v$log;
-
-
GROUP# SEQUENCE# STATUS
-
---------- ---------- ----------------
-
1 52 ACTIVE
-
2 53 ACTIVE
-
3 54 CURRENT
-
-
SYS@seiang11g>alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss';11:38:04 SYS@seiang11g>select name from v$archived_log;
-
-
NAME
-
------------------------------------------------------------
-
………(省略N條歸檔日誌)……….
-
/u01/app/oracle/arch/arch_1_949237404_49.log
-
/u01/app/oracle/arch/arch_1_949237404_50.log
-
/u01/app/oracle/arch/arch_1_949237404_51.log
-
/u01/app/oracle/arch/arch_1_949237404_52.log(test1表的刪除記錄在該歸檔日誌檔案中)
-
/u01/app/oracle/arch/arch_1_949237404_53.log
-
-
-
49 rows selected. SYS@seiang11g>select name,first_time,next_time from v$archived_log;
-
-
NAME FIRST_TIME NEXT_TIME
-
------------------------------------------------------------ ------------------- -------------------
-
……..(此處省略部分歸檔)…………..
-
/u01/app/oracle/arch/arch_1_949237404_49.log 2017-08-01 04:02:47 2017-08-01 15:00:39
-
/u01/app/oracle/arch/arch_1_949237404_50.log 2017-08-01 15:00:39 2017-08-01 22:00:33
-
/u01/app/oracle/arch/arch_1_949237404_51.log 2017-08-01 22:00:33 2017-08-02 00:00:03
-
/u01/app/oracle/arch/arch_1_949237404_52.log 2017-08-02 00:00:03 2017-08-02 11:37:51
-
/u01/app/oracle/arch/arch_1_949237404_53.log 2017-08-02 11:37:51 2017-08-02 11:37:59
-
-
--新增一條日誌條目,該日誌記錄了刪除test1時的歸檔日誌資訊
-
SYS@seiang11g>exec dbms_logmnr.add_logfile(logfilename => '/u01/app/oracle/arch/arch_1_949237404_52.log', options => dbms_logmnr.new);
-
PL/SQL procedure successfully completed.
-
-
--開始解析日誌條目
-
SYS@seiang11g>exec dbms_logmnr.start_logmnr(options => dbms_logmnr.dict_from_online_catalog);
-
PL/SQL procedure successfully completed.
-
-
--檢視v$logmnr_contents檢視,找出刪除test1表時的SCN(1914743)和時間戳
-
SYS@seiang11g>col sql_redo for a50
-
SYS@seiang11g>select scn, timestamp, sql_redo from v$logmnr_contents where seg_owner='SEIANG';
-
-
SCN TIMESTAMP SQL_REDO
-
---------- ------------------- --------------------------------------------------
-
1914743 2017-08-02 11:32:53 drop table seiang.test1 purge;
-
-
--檢視資料檔案頭資訊,挖掘出來的SCN比此時的SCN要小
-
SYS@seiang11g>select file#,name,checkpoint_change# from v$datafile_header;
-
-
FILE# NAME CHECKPOINT_CHANGE#
-
---------- ------------------------------------------------------------ ------------------
-
1 /u01/app/oracle/oradata/OraDB11g/system01.dbf 1915266
-
2 /u01/app/oracle/oradata/OraDB11g/sysaux01.dbf 1915266
-
3 /u01/app/oracle/oradata/OraDB11g/undotbs01.dbf 1915266
-
4 /u01/app/oracle/oradata/OraDB11g/users01.dbf 1915266
-
5 /u01/app/oracle/oradata/OraDB11g/example01.dbf 1915266
-
6 /u01/app/oracle/oradata/OraDB11g/rman01.dbf 1915266
-
7 /u01/app/oracle/oradata/OraDB11g/seiang01.dbf 1915266
-
8 /u01/app/oracle/oradata/OraDB11g/wjq01.dbf 1915266
-
9 /u01/app/oracle/oradata/OraDB11g/wjqbest01.dbf 1915266
-
-
--關閉資料庫,刪除所有的資料檔案
-
SYS@seiang11g>shutdown immediate
-
Database closed.
-
Database dismounted.
-
ORACLE instance shut down.
-
-
[oracle@seiang11g OraDB11g]$ rm *.dbf
-
[oracle@seiang11g OraDB11g]$
-
[oracle@seiang11g OraDB11g]$ ll
-
total 163164
-
-rw-r----- 1 oracle oinstall 9781248 Aug 2 11:55 control01.ctl
-
-rw-r----- 1 oracle oinstall 52429312 Aug 2 11:37 redo01.log
-
-rw-r----- 1 oracle oinstall 52429312 Aug 2 11:37 redo02.log
-
-rw-r----- 1 oracle oinstall 52429312 Aug 2 11:55 redo03.log
-
-
--重新啟動資料庫,由於缺少資料檔案而出現報錯資訊
-
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 1 - see DBWR trace file
-
ORA-01110: data file 1: '/u01/app/oracle/oradata/OraDB11g/system01.dbf'
-
-
--檢視需要恢復的資料檔案
-
SYS@seiang11g>select * from v$recover_file;
-
-
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
-
---------- ------- ------- ----------------------------------------------------------------- ---------- ---------
-
1 ONLINE ONLINE 1913765 02-AUG-17
-
2 ONLINE ONLINE 1913765 02-AUG-17
-
3 ONLINE ONLINE 1913765 02-AUG-17
-
4 ONLINE ONLINE 1913765 02-AUG-17
-
5 ONLINE ONLINE 1913765 02-AUG-17
-
6 ONLINE ONLINE 1913765 02-AUG-17
-
7 ONLINE ONLINE 1913765 02-AUG-17
-
8 ONLINE ONLINE 1913765 02-AUG-17
-
9 ONLINE ONLINE 1913765 02-AUG-17
-
-
-
--還原冷備份的所有資料檔案
-
SYS@seiang11g>host cp /u01/app/oracle/UMAN_Backup/*.dbf /u01/app/oracle/oradata/OraDB11g
--根據挖掘出來的SCN(1914743),執行資料的不完全恢復
SYS@seiang11g>recover database until change 1914743;
Media recovery complete.
或則是(SYS@seiang11g>recover database until time 2017-08-02 11:32:53;)
--恢復完成後,檢視當前日誌序號為54
SYS@seiang11g>select group#,sequence#,status from v$log;
GROUP# SEQUENCE# STATUS
---------- ---------- ----------------
1 52 INACTIVE
3 54 CURRENT
2 53 INACTIVE
--檢視資料檔案頭的SCN,是恢復後最新的SCN
SYS@seiang11g>select file#,name,checkpoint_change# from v$datafile_header;
FILE# NAME CHECKPOINT_CHANGE#
---------- ------------------------------------------------------------ ------------------
1 /u01/app/oracle/oradata/OraDB11g/system01.dbf 1914743
2 /u01/app/oracle/oradata/OraDB11g/sysaux01.dbf 1914743
3 /u01/app/oracle/oradata/OraDB11g/undotbs01.dbf 1914743
4 /u01/app/oracle/oradata/OraDB11g/users01.dbf 1914743
5 /u01/app/oracle/oradata/OraDB11g/example01.dbf 1914743
6 /u01/app/oracle/oradata/OraDB11g/rman01.dbf 1914743
7 /u01/app/oracle/oradata/OraDB11g/seiang01.dbf 1914743
8 /u01/app/oracle/oradata/OraDB11g/wjq01.dbf 1914743
9 /u01/app/oracle/oradata/OraDB11g/wjqbest01.dbf 1914743
--使用resetlogs開啟資料庫
SYS@seiang11g>alter database open resetlogs;
Database altered.
--檢視當前日誌序號從1開始記錄,之前的歸檔日誌全部作廢
SYS@seiang11g>select group#,sequence#,status from v$log;
GROUP# SEQUENCE# STATUS
---------- ---------- ----------------
1 1 CURRENT
2 0 UNUSED
3 0 UNUSED
--刪除的test1表恢復成功
SYS@seiang11g>select * from seiang.test1;
ID NAME AGE
---------- ------------------------------------------------------------ ----------
1 wjq 23
2 seiang 24
恢復原理:
1.冷備份的資料檔案*.dbf比現在要舊,那麼資料檔案的scn肯定就比現在的小;
2.使用日誌挖掘方法,在日誌中找出刪表時的scn或時間戳;
3.在資料庫shutdown的狀態下,用冷備份的資料檔案*.dbf,覆蓋現在的*.dbf檔案;保證資料檔案完整性;
4.啟動資料庫到mount下,恢復到日誌挖掘的SCN或時間點(利用日誌對資料檔案重做一次)
5.以resetlogs方式開啟資料庫,以前的日誌就被覆蓋了;示例二:當前日誌組損壞,造成資料庫崩潰
環境:
(1)提前對資料庫做一次全庫冷備份;
(2)在seiang使用者下有一張test1表隸屬於seiang表空間;
-
-
SYS@seiang11g>select owner,table_name,tablespace_name from dba_tables
-
2 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
-
-
--檢視當前的日誌序號為1
-
SYS@seiang11g>select group#,sequence#,status from v$log;
-
-
GROUP# SEQUENCE# STATUS
-
---------- ---------- ----------------
-
1 1 CURRENT
-
2 0 UNUSED
-
3 0 UNUSED
-
-
--在test1表中插入一條資料,提交,並切換日誌,該插入資訊記錄在歸檔日誌1中
-
SYS@seiang11g>insert into seiang.test1 values(3,'wjqgood',25);
-
1 row created.
-
SYS@seiang11g>commit;
-
Commit complete.
-
SYS@seiang11g>alter system switch logfile;
-
System altered.
-
-
--在test1表中插入一條資料,提交,並切換日誌,該插入資訊記錄在歸檔日誌2中
-
SYS@seiang11g>insert into seiang.test1 values(4,'wjqbest',30);
-
1 row created.
-
SYS@seiang11g>commit;
-
Commit complete.
-
SYS@seiang11g>alter system switch logfile;
-
System altered.
-
-
--檢視當前的日誌序號為3
-
SYS@seiang11g>select group#,sequence#,status from v$log;
-
-
GROUP# SEQUENCE# STATUS
-
---------- ---------- ----------------
-
1 1 ACTIVE
-
2 2 ACTIVE
-
3 3 CURRENT
-
-
--檢視歸檔日誌的資訊
-
SYS@seiang11g>select name from v$archived_log;
-
-
NAME
-
--------------------------------------------------------
-
/u01/app/oracle/arch/arch_1_950971495_1.log
-
/u01/app/oracle/arch/arch_1_950971495_2.log
-
-
--在test1表中插入一條資料,提交,不切換日誌,該插入資訊記錄在當前日誌3中
-
SYS@seiang11g>insert into seiang.test1 values(5,'wjqseiang',60);
-
1 row created.
-
SYS@seiang11g>commit;
-
Commit complete.
-
-
--檢視test1表中現有的資料資訊
-
SYS@seiang11g>select * from seiang.test1;
-
-
ID NAME AGE
-
---------- ------------------------------ ----------
-
1 wjq 23
-
2 seiang 24
-
3 wjqgood 25(在歸檔arch_1_950971495_1.log)
-
4 wjqbest 30(在歸檔arch_1_950971495_2.log)
-
5 wjqseiang 60(在當前日誌redo03.log)
-
-
-
--模擬當前日誌丟失或損壞,資料庫崩潰
-
[oracle@seiang11g OraDB11g]$ rm redo03.log
-
SYS@seiang11g>shutdown abort
-
ORACLE instance shut down.
-
-
-
--啟動資料庫,由於缺少當前日誌資訊出現報錯資訊
-
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-00313: open failed for members of log group 3 of thread 1
-
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/OraDB11g/redo03.log'
-
ORA-27037: unable to obtain file status
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 3
-
-
--還原所有的冷備份資料檔案
-
[oracle@seiang11g OraDB11g]$ rm *.dbf
-
[oracle@seiang11g OraDB11g]$
-
[oracle@seiang11g OraDB11g]$ ll
-
total 163164
-
-rw-r----- 1 oracle oinstall 9781248 Aug 2 14:57 control01.ctl
-
-rw-r----- 1 oracle oinstall 52429312 Aug 2 14:56 redo01.log
-
-rw-r----- 1 oracle oinstall 52429312 Aug 2 14:56 redo02.log
- -rw-r----- 1 oracle oinstall 52429312 Aug 2 14:56 redo03.log.bak
-
[oracle@seiang11g OraDB11g]$ cp /u01/app/oracle/UMAN_Backup/*.dbf ./
-
在這裡一定要注意的的是,一定要還原所有舊的冷備份的資料檔案,如果不還原的話,就會出現如下的問題:
-
SYS@seiang11g>recover database until cancel;
-
ORA-00279: change 1921883 generated at 08/02/2017 14:28:01 needed for thread 1
-
ORA-00289: suggestion : /u01/app/oracle/arch/arch_1_950971495_3.log
-
ORA-00280: change 1921883 for thread 1 is in sequence #3
-
-
-
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
-
cancel
-
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
-
ORA-01194: file 1 needs more recovery to be consistent
-
ORA-01110: data file 1: '/u01/app/oracle/oradata/OraDB11g/system01.dbf'
-
-
ORA-01112: media recovery not started
-
-
-
-
--嘗試進行手工完全恢復,由於缺少當前日誌失敗
-
SYS@seiang11g>recover database;
-
ORA-00283: recovery session canceled due to errors
-
ORA-00313: open failed for members of log group 3 of thread 1
-
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/OraDB11g/redo03.log'
-
ORA-27037: unable to obtain file status
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 3
-
-
-
--執行不完全恢復
-
SYS@seiang11g>recover database until cancel;
-
ORA-00279: change 1914401 generated at 08/02/2017 14:49:14 needed for thread 1
-
ORA-00289: suggestion : /u01/app/oracle/arch/arch_1_950971495_3.log(注意提示資訊)
-
ORA-00280: change 1914401 for thread 1 is in sequence #3
-
(該歸檔日誌不存在)
-
-
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
-
cancel
-
Media recovery cancelled.
-
-
--恢復完成後,使用resetlogs開啟資料庫
-
SYS@seiang11g>alter database open resetlogs;
-
Database altered.
-
-
--檢視當前日誌序號重新從1開始記錄
-
SYS@seiang11g>select group#,sequence#,status from v$log;
-
-
GROUP# SEQUENCE# STATUS
-
---------- ---------- ----------------
-
1 1 CURRENT
-
2 0 UNUSED
-
3 0 UNUSED
-
-
--檢視錶test1中的資料資訊
-
SYS@seiang11g>select * from seiang.test1;
-
-
ID NAME AGE
-
---------- ------------------------------ ----------
-
1 wjq 23
-
2 seiang 24
-
3 wjqdood 25
-
4 wjqbest 30
- 可以發現儲存在當前日誌檔案中的資料記錄被回滾掉了!!!
示例三:歸檔日誌丟失或損壞
環境:
(1)提前有一套完成的資料檔案的冷備份;
(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
-
-
--檢視當前日誌序號為2
-
SYS@seiang11g>select group#,sequence#,status from v$log;
-
-
GROUP# SEQUENCE# STATUS
-
---------- ---------- ----------------
-
1 1 INACTIVE
-
2 2 CURRENT
-
3 0 UNUSED
-
-
-
--修改資料並提交(sequence號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.
-
-
--修改資料並提交(sequence號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.
-
-
--修改資料並提交(sequence號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.
-
-
--修改資料並提交(sequence號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.
-
-
--修改資料並提交(sequence號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.
-
-
--修改資料並提交(sequence號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.
-
-
--當前聯機日誌序號為8
-
SYS@seiang11g>select group#,sequence#,status from v$log;
-
-
GROUP# SEQUENCE# STATUS
-
---------- ---------- ----------------
-
1 7 ACTIVE
-
2 8 CURRENT
-
3 6 ACTIVE
-
-
--檢視相應的歸檔日誌
-
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
-
-
--關閉資料庫
-
SYS@seiang11g >shutdown immediate
-
Database closed.
-
Database dismounted.
-
ORACLE instance shut down.
-
-
--模擬資料檔案seiang損壞
-
SYS@seiang11g>host rm /u01/app/oracle/oradata/OraDB11g/seiang01.dbf
-
-
-
--重新開啟資料庫 ,由於資料檔案的丟死,資料庫無法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
-
-
--還原備份的資料檔案
-
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
-
-
-
--檢視一下歸檔日誌的詳細資訊
-
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
-
-
-
--執行恢復操作,當在需要歸檔日誌5的時候出現錯誤
-
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
-
-
--檢視資料檔案頭,發現檢查點不一致
-
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
-
--關閉資料庫 ,還原所有冷備份的資料檔案
SYS@seiang11g>shutdown abort
ORACLE instance shut down.
SYS@seiang11g>host cp /u01/app/oracle/UMAN_Backup/*.dbf /u01/app/oracle/oradata/OraDB11g/
-
SYS@seiang11g>host ls -l /u01/app/oracle/oradata/OraDB11g/
-
total 2279068
-
-rw-r----- 1 oracle oinstall 7680 Aug 2 16:08 arch_1_950972396_5.log
-
-rw-r----- 1 oracle oinstall 9781248 Aug 2 16:16 control01.ctl
-
-rw-r----- 1 oracle oinstall 363077632 Aug 2 16:17 example01.dbf
-
-rw-r----- 1 oracle oinstall 52429312 Aug 2 15:52 redo01.log
-
-rw-r----- 1 oracle oinstall 52429312 Aug 2 15:58 redo02.log
-
-rw-r----- 1 oracle oinstall 52429312 Aug 2 15:52 redo03.log
-
-rw-r----- 1 oracle oinstall 31465472 Aug 2 16:17 rman01.dbf
-
-rw-r----- 1 oracle oinstall 73408512 Aug 2 16:17 seiang01.dbf
-
-rw-r----- 1 oracle oinstall 734011392 Aug 2 16:18 sysaux01.dbf
-
-rw-r----- 1 oracle oinstall 796925952 Aug 2 16:18 system01.dbf
-
-rw-r----- 1 oracle oinstall 30416896 Aug 2 16:18 temp01.dbf
-
-rw-r----- 1 oracle oinstall 110108672 Aug 2 16:18 undotbs01.dbf
-
-rw-r----- 1 oracle oinstall 5251072 Aug 2 16:18 users01.dbf
-
-rw-r----- 1 oracle oinstall 20979712 Aug 2 16:18 wjq01.dbf
-
-rw-r----- 1 oracle oinstall 20979712 Aug 2 16:18 wjqbest01.dbf
-
-
--重新開啟資料庫
-
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-01190: control file or data file 1 is from before the last RESETLOGS
-
ORA-01110: data file 1: '/u01/app/oracle/oradata/OraDB11g/system01.dbf'
-
-
-
SYS@seiang11g>select file#,name,checkpoint_change# from v$datafile_header;
-
-
FILE# NAME CHECKPOINT_CHANGE#
-
---------- -------------------------------------------------- ------------------
-
1 /u01/app/oracle/oradata/OraDB11g/system01.dbf 1913765
-
2 /u01/app/oracle/oradata/OraDB11g/sysaux01.dbf 1913765
-
3 /u01/app/oracle/oradata/OraDB11g/undotbs01.dbf 1913765
-
4 /u01/app/oracle/oradata/OraDB11g/users01.dbf 1913765
-
5 /u01/app/oracle/oradata/OraDB11g/example01.dbf 1913765
-
6 /u01/app/oracle/oradata/OraDB11g/rman01.dbf 1913765
-
7 /u01/app/oracle/oradata/OraDB11g/seiang01.dbf 1913765
-
8 /u01/app/oracle/oradata/OraDB11g/wjq01.dbf 1913765
-
9 /u01/app/oracle/oradata/OraDB11g/wjqbest01.dbf 1913765
-
-
9 rows selected.
-
-
--恢復資料庫 ,首先嚐試完全恢復,同樣在需要歸檔日誌5的時候出現錯誤
-
SYS@seiang11g>recover database;
-
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
-
-
-
--執行不完全恢復 ,成功
-
SYS@seiang11g>recover database until cancel;
-
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
-
-
-
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
-
cancel
-
Media recovery cancelled.
-
-
--再次檢視資料檔案頭的相關資訊
-
SYS@seiang11g>select file#,name,checkpoint_change# from v$datafile_header;
-
-
FILE# NAME CHECKPOINT_CHANGE#
-
---------- -------------------------------------------------- ------------------
-
1 /u01/app/oracle/oradata/OraDB11g/system01.dbf 1937110
-
2 /u01/app/oracle/oradata/OraDB11g/sysaux01.dbf 1937110
-
3 /u01/app/oracle/oradata/OraDB11g/undotbs01.dbf 1937110
-
4 /u01/app/oracle/oradata/OraDB11g/users01.dbf 1937110
-
5 /u01/app/oracle/oradata/OraDB11g/example01.dbf 1937110
-
6 /u01/app/oracle/oradata/OraDB11g/rman01.dbf 1937110
-
7 /u01/app/oracle/oradata/OraDB11g/seiang01.dbf 1937110
-
8 /u01/app/oracle/oradata/OraDB11g/wjq01.dbf 1937110
-
9 /u01/app/oracle/oradata/OraDB11g/wjqbest01.dbf 1937110
-
-
--檢視日誌組資訊,發現與5號脫節
-
SYS@seiang11g>select group#,sequence#,status from v$log;
-
-
GROUP# SEQUENCE# STATUS
-
---------- ---------- ----------------
-
1 7 INACTIVE
-
3 6 INACTIVE
-
2 8 CURRENT
-
-
--使用resetlogs開啟資料庫
-
SYS@seiang11g>alter database open resetlogs;
-
Database altered.
-
-
--日誌序號從1開始記錄
-
SYS@seiang11g>select group#,sequence#,status from v$log;
-
-
GROUP# SEQUENCE# STATUS
-
---------- ---------- ----------------
-
1 1 CURRENT
-
2 0 UNUSED
-
3 0 UNUSED
-
-
--確認表中的資料資訊,發現在5號歸檔日誌丟失後的修改都沒有生效
-
SYS@seiang11g>select * from seiang.test1;
-
-
ID NAME AGE
-
---------- -------------------------------------------------- ----------
-
1 wjq 300
-
2 seiang 24
-
3 wjqdood 25
- 4 wjqbest 30
相關連線:
Oracle手工完全恢復案例:http://blog.itpub.net/31015730/viewspace-2142669/作者:SEian.G(苦練七十二變,笑對八十一難)
ITPUB:http://blog.itpub.net/31015730/
51CTO:http://seiang.blog.51cto.com/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31015730/viewspace-2142995/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle手工不完全恢復(二):使用備份控制檔案Oracle
- 手工恢復控制檔案
- 當前控制檔案全部丟失恢復
- 【備份與恢復】控制檔案的恢復(不完全恢復)
- Oracle 11g 手工不完全恢復Oracle
- 控制檔案重建後的不完全恢復
- rman恢復:資料檔案丟失,控制檔案丟失,聯機日誌檔案丟失(非當前使用與當前使用)
- 使用rman恢復控制檔案
- 小記基於控制檔案的scn不完全恢復
- 舊控制檔案的不完全恢復(sqlplus工具)SQL
- Oracle 11g 手工不完全恢復 場景1:被動的不完全恢復(日誌缺失)Oracle
- 控制檔案的恢復方法(一)
- 控制檔案恢復—從trace檔案中恢復
- 當oracle丟失所有控制檔案後可以重新建立控制檔案來恢復資料庫Oracle資料庫
- 使用舊的控制檔案備份來恢復控制檔案
- Oracle備份與恢復【丟失控制檔案的恢復】Oracle
- RMAN備份恢復之控制檔案的恢復(一)
- Oracle 不完全恢復Oracle
- RMAN恢復控制檔案
- 測試恢復5==使用2進位制形式檔案恢復控制檔案
- 控制檔案恢復—從快照中恢復
- 恢復測試:擁有當時的全部歸檔,控制檔案,恢復丟失的資料檔案。
- 循序漸進oracle第7章:備份與恢復之利用控制檔案快照恢復控制檔案Oracle
- Oracle手工完全恢復案例Oracle
- rman恢復--丟失控制檔案的恢復
- 【管理篇備份恢復】rman恢復測試(二) 控制檔案恢復(一)
- Oracle 11g RAMN恢復-控制檔案的備份和恢復Oracle
- oracle實驗記錄 (恢復-rman基於控制檔案的恢復)Oracle
- word怎麼恢復儲存前的檔案,word檔案恢復
- 【備份恢復】利用 備份控制檔案到指定目錄下的控制檔案 恢復控制檔案
- cp方式恢復控制檔案
- 控制檔案恢復測試
- 控制檔案丟失恢復
- 【控制檔案丟失恢復】
- rman恢復spfile和control和resetlogs建立控制檔案和不完全恢復疑點
- 【備份恢復】 丟失一個控制檔案 之恢復操作
- [裝載]oracle 無歸檔的不完全恢復Oracle
- 恢復控制檔案避免使用resetlogs選項