聯機記錄檔狀態為active或current表示該日誌包含的資料修改還未完全同步到資料文 件中,在執行個體恢複時,還需要讀取其中的redo記錄重演,因此如果損壞,資料丟失在所難免 。
1)類比災難
首先查看log的狀態:
SQL> select group#,sequence#,status from v$log;
GROUP# SEQUENCE# STATUS
------ ---- ---------- ----------------
2 5 CURRENT
3 3 INACTIVE
4 4 INACTIVE
Group#2的狀態為current,我們找出它所對應的磁碟檔案為:
SQL> select group#,member from v$logfile where group#=2;
GROUP# MEMBER
------ ---- ---------------------------------------------------------
2 J:\INTEL_LOG\O04DMS0\REDO02.O04DMS0
如果資料庫時正常關閉,在關閉之前,會做一次資料檔案同步,因此為了類比current文 件丟失的情況,我們異常關閉資料庫:
SQL> shutdown abort;
然後把Group#2對應 的檔案REDO02.O04DMS0在作業系統層級上刪除。
2)根據錯誤資訊定位問題
啟動數 據庫會出現以下錯誤
SQL> startup
ORACLE instance started.
Total System Global Area 281018368 bytes
Fixed Size 1296292 bytes
Variable Size 251660380 bytes
Database Buffers 25165824 bytes
Redo Buffers 2895872 bytes
Database mounted.
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: 'J:\INTEL_LOG\O04DMS0\REDO02.O04DMS0'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) The system cannot find the file specified.
由於有一組記錄檔丟失, 因此資料庫只能mount,無法open,查看一下丟失的記錄檔是什麼狀態:
SQL> select group#,sequence#,status from v$log where group#=2;
GROUP# SEQUENCE# STATUS
---------- ---------- ----------------
2 5CURRENT