Oracle 登錄產(chǎn)生了01033錯誤 |
發(fā)布時間: 2012/8/13 17:01:30 |
損壞聯(lián)機日志的恢復方法 損壞非當前聯(lián)機日志 大家都清楚,聯(lián)機日志分為當前聯(lián)機日志和非當前聯(lián)機日志,非當前聯(lián)機日志的損壞是比較簡單的,一般通過clear命令就可以解決問題。 1、啟動數(shù)據(jù)庫,遇到ORA-00312 or ORA-00313錯誤,如 ORA-00313: open failed for members of log group 1 of thread 1 ORA-00312: online log 1 thread 1: 'D:\Oracle\ORADATA\TEST\REDO01.LOG' 從這里我們知道日志組1的數(shù)據(jù)文件損壞了 從報警文件可以看到更詳細的信息 2、查看V$log視圖 SQL> select group#,sequence#,archived,status from v$log; GROUP# SEQUENCE# ARCHIVED STATUS ---------- ---------- -------- ---------------- 1 1 YES INACTIVE 2 2 YES INACTIVE 3 3 NO CURRENT 可以知道,該組是非當前狀態(tài),而且已經(jīng)歸檔。 3、用CLEAR命令重建該日志文件 SQL>alter database clear logfile group 1; 如果是該日志組還沒有歸檔,則需要用 SQL>alter database clear unarchived logfile group 1; 4、打開數(shù)據(jù)庫,重新備份數(shù)據(jù)庫 SQL>alter database open; 說明: 1、如果損壞的是非當前的聯(lián)機日志文件,一般只需要clear就可以重建該日志文件,但是如果該數(shù)據(jù)庫處于歸檔狀態(tài)但該日志還沒有歸檔,就需要強行clear。 2、建議clear,特別是強行clear后作一次數(shù)據(jù)庫的全備份。 3、此方法適用于歸檔與非歸檔數(shù)據(jù)庫 5.1.2 損壞當前聯(lián)機日志 歸檔模式下當前日志的損壞有兩種情況, 一、是數(shù)據(jù)庫是正常關(guān)閉,日志文件中沒有未決的事務需要實例恢復,當前日志組的損壞就可以直接用alter database clear unarchived logfile group n來重建。 二、是日志組中有活動的事務,數(shù)據(jù)庫需要媒體恢復,日志組需要用來同步,有兩種補救辦法 A. 最好的辦法就是通過不完全恢復,可以保證數(shù)據(jù)庫的一致性,但是這種辦法要求在歸檔方式下,并且有可用的備份 B. 通過強制性恢復,但是可能導致數(shù)據(jù)庫不一致。 下面分別用來說明這兩種恢復方法 5.1.2.1 通過備份來恢復 1、打開數(shù)據(jù)庫,會遇到一個類似的錯誤 ORA-00313: open failed for members of log group 1 of thread 1 ORA-00312: online log 1 thread 1: 'D:\Oracle\ORADATA\TEST\REDO01.LOG' ORA-27041: unable to open file OSD-04002: unable to open file O/S-Error: (OS 2) 系統(tǒng)找不到指定的文件 2、查看V$log,發(fā)現(xiàn)是當前日志 SQL> select group#,sequence#,archived,status from v$log; GROUP# SEQUENCE# ARCHIVED STATUS ---------- ---------- -------- ---------------- 1 1 NO CURRENT 2 2 YES INACTIVE 3 3 YES INACTIVE 3、發(fā)現(xiàn)clear不成功 SQL> alter database clear unarchived logfile group 1; alter database clear unarchived logfile group 1 * ERROR at line 1: ORA-01624: log 1 needed for crash recovery of thread 1 ORA-00312: online log 1 thread 1: 'D:\Oracle\ORADATA\TEST\REDO01.LOG' 4、拷貝有效的數(shù)據(jù)庫的全備份,并不完全恢復數(shù)據(jù)庫 可以采用獲取最近的SCN的辦法用until scn恢復或用until cnacel恢復 recover database until cancel 先選擇auto,盡量恢復可以利用的歸檔日志,然后重新 recover database until cancel 這次輸入cancel,完成不完全恢復,也就是說恢復兩次。 如: SQL> recover database until cancel; Auto …… SQL> recover database until cancel; Cancel; 5、利用alter database open resetlogs打開數(shù)據(jù)庫 說明: 1、這種辦法恢復的數(shù)據(jù)庫是一致的不完全恢復,會丟失當前聯(lián)機日志中的事務數(shù)據(jù) 2、這種方法適合于歸檔數(shù)據(jù)庫并且有可用的數(shù)據(jù)庫全備份。 3、恢復成功之后,記得再做一次數(shù)據(jù)庫的全備份。 4、建議聯(lián)機日志文件一定要實現(xiàn)鏡相在不同的磁盤上,避免這種情況的發(fā)生,因為任何數(shù)據(jù)的丟失對于生產(chǎn)來說都是不容許的。 5.1.2.2 如果沒有備份,進行強制性恢復 1、打開數(shù)據(jù)庫,會遇到一個類似的錯誤 ORA-00313: open failed for members of log group 1 of thread 1 ORA-00312: online log 1 thread 1: 'D:\Oracle\ORADATA\TEST\REDO01.LOG' ORA-27041: unable to open file OSD-04002: unable to open file O/S-Error: (OS 2) 系統(tǒng)找不到指定的文件 2、查看V$log,發(fā)現(xiàn)是當前日志 SQL> select group#,sequence#,archived,status from v$log; GROUP# SEQUENCE# ARCHIVED STATUS ---------- ---------- -------- ---------------- 1 1 NO CURRENT 2 2 YES INACTIVE 3 3 YES INACTIVE 3、發(fā)現(xiàn)clear不成功 SQL> alter database clear unarchived logfile group 1; alter database clear unarchived logfile group 1 * ERROR at line 1: ORA-01624: log 1 needed for crash recovery of thread 1 ORA-00312: online log 1 thread 1: 'D:\Oracle\ORADATA\TEST\REDO01.LOG' 4、把數(shù)據(jù)庫down掉 SQL>shutdown immediate 5、在init<sid>.ora中加入如下參數(shù) _allow_resetlogs_corruption=TRUE 6、重新啟動數(shù)據(jù)庫,利用until cancel恢復 SQL>recover database until cancel; Cancel 如果出錯,不再理會,發(fā)出 SQL>alter database open resetlogs; 7、數(shù)據(jù)庫被打開后,馬上執(zhí)行一個full export 8、shutdown數(shù)據(jù)庫,去掉_all_resetlogs_corrupt參數(shù) 9、重建庫 10、import并完成恢復 11、建議執(zhí)行一下ANALYZE TABLE ...VALIDATE STRUCTURE CASCADE; 說明: 1、該恢復方法是沒有辦法之后的恢復方法,一般情況下建議不要采用,因為該方法可能導致數(shù)據(jù)庫的不一致 2、該方法也丟失數(shù)據(jù),但是丟失的數(shù)據(jù)沒有上一種方法的數(shù)據(jù)多,主要是未寫入數(shù)據(jù)文件的已提交或未提交數(shù)據(jù)。 3、建議成功后嚴格執(zhí)行以上的7到11步,完成數(shù)據(jù)庫的檢查與分析 4、全部完成后做一次數(shù)據(jù)庫的全備份 5、建議聯(lián)機日志文件一定要實現(xiàn)鏡相在不同的磁盤上,避免這種情況的發(fā)生,因為任何數(shù)據(jù)的丟失對于生產(chǎn)來說都是不容許的。 本文出自:億恩科技【www.cmtents.com】 |