誤刪重做日誌檔案組導致啟動資料庫報錯ORA-03113

Hoegh發表於2015-07-09
        聽不止一個人說起,學技術就要不斷地折騰、搞破壞,比如說備份恢復,你就可以嘗試刪檔案,不管是日誌檔案、臨時檔案、資料檔案還是system檔案。刪了之後,重啟資料庫肯定報錯,有的甚至當時資料庫就掛掉,這樣你就可以學著恢復,一破一立之間,很多常規的備份恢復手段也就算是領教了。我今天就嘗試著把虛擬機器上的一個重做日誌檔案組刪除。

1.環境準備

我們在Oracle11g中進行測試,資料庫處於非歸檔狀態。

點選(此處)摺疊或開啟

  1. SQL>

  2. SQL> select * from v$version;

  3.  

  4. BANNER

  5. --------------------------------------------------------------------------------

  6. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production

  7. PL/SQL Release 11.2.0.3.0 - Production

  8. CORE 11.2.0.3.0 Production

  9. TNS for Linux: Version 11.2.0.3.0 - Production

  10. NLSRTL Version 11.2.0.3.0 - Production

  11.  

  12. SQL>

  13. SQL> archive log list;

  14. Database log mode No Archive Mode

  15. Automatic archival Disabled

  16. Archive destination /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch

  17. Oldest online log sequence 9

  18. Current log sequence 11

  19. SQL>

2.刪除一個重做日誌檔案組,重啟資料庫報錯

首先,透過查詢v$log檢視來獲取資料庫重做日誌檔案組的狀態。

點選(此處)摺疊或開啟

  1. SQL> select GROUP#,MEMBERS,ARCHIVED,STATUS from v$log;

  2.  

  3.     GROUP# MEMBERS ARC STATUS

  4. ---------- ---------- --- ----------------

  5.          1 1 NO INACTIVE

  6.          2 1 NO CURRENT

  7.          3 1 NO INACTIVE

  8.  

  9. SQL>
然後,透過ls命令檢視資料檔案,刪除第一個重做日誌檔案組(該檔案組只有一個日誌成員)。

點選(此處)摺疊或開啟

  1. [oracle@ hoegh HOEGH]$ ls

  2. control01.ctl redo01.log sysaux01.dbf undotbs01.dbf

  3. control02.ctl redo02.log system01.dbf users01.dbf

  4. example01.dbf redo03.log temp01.dbf

  5. [oracle@hoegh HOEGH]$

  6. [oracle@hoegh HOEGH]$

  7. [oracle@hoegh HOEGH]$ rm redo01.log

  8. [oracle@hoegh HOEGH]$ ls

  9. control01.ctl control02.ctl example01.dbf redo02.log redo03.log sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf
重啟資料庫,資料庫報錯。

點選(此處)摺疊或開啟

  1. SQL>

  2. SQL> shu immediate

  3. Database closed.

  4. Database dismounted.

  5. ORACLE instance shut down.

  6. SQL> startup

  7. ORACLE instance started.

  8.  

  9. Total System Global Area 941600768 bytes

  10. Fixed Size 1348860 bytes

  11. Variable Size 515902212 bytes

  12. Database Buffers 419430400 bytes

  13. Redo Buffers 4919296 bytes

  14. Database mounted.

  15. ORA-03113: end-of-file on communication channel

  16. Process ID: 5196

  17. Session ID: 125 Serial number: 5

  18.  

  19.  

  20. SQL>

  21. SQL> select status from v$instance;

  22. ERROR:

  23. ORA-03114: not connected to ORACLE

  24.  

  25.  

  26. SQL>


3.檢視報警日誌檔案,定位問題

ORA-03113報錯是一個非常經典的報錯,報錯原因多種多樣,從報錯資訊中並看不出是什麼原因導致的報錯,我們可以到報警日誌檔案中檢視有價值的線索。

點選(此處)摺疊或開啟

  1. [oracle@enmoedu1 trace]$ tail -40 alert_HOEGH.log

  2. Wed Jul 08 21:59:30 2015

  3. MMON started with pid=15, OS id=5443

  4. Wed Jul 08 21:59:30 2015

  5. MMNL started with pid=16, OS id=5445

  6. starting up 1 dispatcher(s) for network address \'(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))\'...

  7. starting up 1 shared server(s) ...

  8. ORACLE_BASE from environment = /u01/app/oracle

  9. Wed Jul 08 21:59:39 2015

  10. alter database mount

  11. Wed Jul 08 21:59:43 2015

  12. Successful mount of redo thread 1, with mount id 2105928075

  13. Database mounted in Exclusive Mode

  14. Lost write protection disabled

  15. Completed: alter database mount

  16. Wed Jul 08 22:11:45 2015

  17. Time drift detected. Please check VKTM trace file for more details.

  18. Wed Jul 08 22:11:59 2015

  19. alter database open

  20. Wed Jul 08 22:11:59 2015

  21. Errors in file /u01/app/oracle/diag/rdbms/HOEGH/HOEGH/trace/HOEGH_lgwr_5435.trc:

  22. ORA-00313: open failed for members of log group 1 of thread 1

  23. ORA-00312: online log 1 thread 1: \'/u01/app/oracle/oradata/HOEGH/redo01.log\'

  24. ORA-27037: unable to obtain file status

  25. Linux Error: 2: No such file or directory

  26. Additional information: 3

  27. Errors in file /u01/app/oracle/diag/rdbms/HOEGH/HOEGH/trace/HOEGH_lgwr_5435.trc:

  28. ORA-00313: open failed for members of log group 1 of thread 1

  29. ORA-00312: online log 1 thread 1: \'/u01/app/oracle/oradata/HOEGH/redo01.log\'

  30. ORA-27037: unable to obtain file status

  31. Linux Error: 2: No such file or directory

  32. Additional information: 3

  33. Errors in file /u01/app/oracle/diag/rdbms/HOEGH/HOEGH/trace/HOEGH_ora_5451.trc:

  34. ORA-00313: open failed for members of log group 1 of thread

  35. ORA-00312: online log 1 thread 1: \'/u01/app/oracle/oradata/HOEGH/redo01.log\'

  36. USER (ospid: 5451): terminating the instance due to error 313

  37. Wed Jul 08 22:12:00 2015

  38. System state dump requested by (instance=1, osid=5451), summary=[abnormal instance termination].

  39. System State dumped to trace file /u01/app/oracle/diag/rdbms/HOEGH/HOEGH/trace/HOEGH_diag_5425.trc

  40. Dumping diagnostic data in directory=[cdmp_20150708221200], requested by (instance=1, osid=5451), summary=[abnormal instance termination].

  41. Instance terminated by USER, pid = 5451
其中,黃色標註部分為關鍵資訊,我們知道“/u01/app/oracle/oradata/HOEGH/redo01.log”這個檔案找不到了。

4.啟動資料庫到mount狀態,重建重做日誌檔案組

從報警日誌可以看出,第一組重做日誌檔案組丟了,我們可以透過sql語句“alter database  clear logfile group 1;”重建日誌檔案組;確認日誌檔案建立成功後,將資料庫切換到open狀態。

點選(此處)摺疊或開啟

  1. SQL> startup nomount

  2. ORACLE instance started.

  3.  

  4. Total System Global Area 941600768 bytes

  5. Fixed Size 1348860 bytes

  6. Variable Size 515902212 bytes

  7. Database Buffers 419430400 bytes

  8. Redo Buffers 4919296 bytes

  9. SQL> alter database mount;

  10.  

  11. Database altered.

  12.  

  13. SQL> select group#,sequence#,archived,status from v$log;

  14.  

  15.     GROUP# SEQUENCE# ARC STATUS

  16. ---------- ---------- --- ----------------

  17.          1 7 NO INACTIVE

  18.          3 6 NO INACTIVE

  19.          2 8 NO CURRENT

  20.  

  21. SQL>

  22. SQL>

  23. SQL>

  24. SQL>

  25. SQL> alter database clear logfile group 1;

  26.  

  27. Database altered.

  28.  

  29. SQL> select group#,sequence#,archived,status from v$log;

  30.  

  31.     GROUP# SEQUENCE# ARC STATUS

  32. ---------- ---------- --- ----------------

  33.          1 0 NO UNUSED

  34.          3 6 NO INACTIVE

  35.          2 8 NO CURRENT

  36.  

  37.  

  38. 啟動資料庫到open狀態

  39. SQL>

  40. SQL> alter database open;

  41.  

  42. Database altered.

  43.  

  44. SQL>

  45. SQL> select group#,sequence#,archived,status from v$log;

  46.  

  47.     GROUP# SEQUENCE# ARC STATUS

  48. ---------- ---------- --- ----------------

  49.          1 0 NO UNUSED

  50.          2 8 NO CURRENT

  51.          3 6 NO INACTIVE
此時我們再次檢視檔案列表,結果如下。

點選(此處)摺疊或開啟

  1. [oracle@hoegh HOEGH]$ ls

  2. control01.ctl control02.ctl example01.dbf redo01.log redo02.log redo03.log sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf

  3. [oracle@hoegh HOEGH]$

5.手動切換重做日誌檔案組

為了確保新建的日誌檔案組可用,我們可以手動切換日誌檔案組,改變新建日誌檔案組的狀態(由UNUSED改為其他)。

點選(此處)摺疊或開啟

  1. SQL>

  2. SQL> alter system switch logfile;

  3.  

  4. System altered.

  5.  

  6. SQL> select group#,sequence#,archived,status from v$log;

  7.  

  8.     GROUP# SEQUENCE# ARC STATUS

  9. ---------- ---------- --- ----------------

  10.          1 9 NO CURRENT

  11.          2 8 NO ACTIVE

  12.          3 6 NO INACTIVE

  13.  

  14. SQL> alter system switch logfile;

  15.  

  16. System altered.

  17.  

  18. SQL> select group#,sequence#,archived,status from v$log;

  19.  

  20.     GROUP# SEQUENCE# ARC STATUS

  21. ---------- ---------- --- ----------------

  22.          1 9 NO ACTIVE

  23.          2 8 NO ACTIVE

  24.          3 10 NO CURRENT

  25.  

  26. SQL> alter system switch logfile;

  27.  

  28. System altered.

  29.  

  30. SQL> select group#,sequence#,archived,status from v$log;

  31.  

  32.     GROUP# SEQUENCE# ARC STATUS

  33. ---------- ---------- --- ----------------

  34.          1 9 NO INACTIVE

  35.          2 11 NO CURRENT

  36.          3 10 NO INACTIVE

  37.  

  38. SQL>
其中,
current:表示該日誌組為當前日誌組,oracle正在使用該日誌組;
active:當current redo組發生日誌切換時,狀態會改變為active,在這個狀態下,如果為歸檔模式,archive程式會歸檔active日誌組;如果發生資料庫crash,該日誌組也是例項恢復必需的日誌組;
inactive:當active日誌組歸檔完畢並且oracle判斷不需要進行例項恢復時,會將其狀態修改為inactive,等待下一輪的使用;所以當日志組為inactive的時候,如果資料庫為歸檔模式.那麼日誌肯定是歸檔完成了。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30162081/viewspace-1727538/,如需轉載,請註明出處,否則將追究法律責任。

相關文章