亚洲免费日韩av一区,最近2019中文字幕大全视频10,体育生gay自慰网站,麻豆国产精品va在线观看不卡

搜索
Close this search box.

Oracle數(shù)據(jù)庫UNDO損壞后的恢復

作者:admin 發(fā)布日期:2016-10-17 16:53:45

Oracle數(shù)據(jù)庫UNDO損壞后的恢復

UNDO表空間存儲著DML操作數(shù)據(jù)塊的前鏡像數(shù)據(jù),在數(shù)據(jù)回滾,一致性讀,閃回操作,實例恢復的時候都可能用到UNDO表空間中的數(shù)據(jù)。如果在生產(chǎn)過程中丟失或破壞了UNDO表空間,可能導致某些事務無法回滾,數(shù)據(jù)庫無法恢復到一致性的狀態(tài),Oracle實例可能宕機,之后實例無法正常啟動;如果有多個UNDO表空間數(shù)據(jù)文件,丟失其中一個數(shù)據(jù)文件數(shù)據(jù)庫實例可能不會導致實例宕機,數(shù)據(jù)庫無法干凈的關閉(只能SHUTDOWN ABORT),數(shù)據(jù)庫實例能正常的重啟,但所有未回滾的數(shù)據(jù)塊依然無法處理,嘗試新建UNDO表空間、exp、expdp等操作都會收到ORA-604, ORA-376, and ORA-1110的報錯,下面通過一個實際的案例討論如何處理UNDO損壞后的恢復。

Oracle數(shù)據(jù)庫數(shù)據(jù)恢復

    客戶的某系統(tǒng)數(shù)據(jù)庫運行在HP-UX服務器上,數(shù)據(jù)庫版本10.2.0.5,單機數(shù)據(jù)庫,數(shù)據(jù)庫運行在非歸檔模式,數(shù)據(jù)庫文件存放在裸設備上。由于操作系統(tǒng)某文件系統(tǒng)空間不夠,維護工程師準備擴展該文件系統(tǒng)的大小,由于在生產(chǎn)時段的一個誤操作(誤以為不會影響系統(tǒng)運行的一個操作)導致文件系統(tǒng)不能正常工作,卸載之后無法掛載,不巧的是不知道是誰之前為數(shù)據(jù)庫的UNDO表空間和TEMP表空間都添加了一個數(shù)據(jù)文件到該文件系統(tǒng)下。這個操作導致某些事務掛起無法回滾,數(shù)據(jù)庫不能正常關閉,但能成功重啟,重啟后事務依然存在,回滾段顯示狀態(tài)依然ONLINE,嘗試新建UNDO表空間收到ORA-604, ORA-376, and ORA-1110,也無法執(zhí)行exp、expdp操作,告警日志一直在報ORA-604, ORA-376, and ORA-1110的錯誤。

    出現(xiàn)這種情況首先我們要確定是否有事務受到影響,確定影響范圍,之后嘗試恢復丟失的數(shù)據(jù)文件(如果在歸檔模式利用備份和歸檔、在線日志恢復丟失的文件),但該客戶的數(shù)據(jù)庫運行在非歸檔模式,無法對數(shù)據(jù)文件進行恢復操作。備份重于一切,一切工作都要圍繞數(shù)據(jù)安全來開展!

下面是處理過程:
   
    我們的基本思維應該是新建一個UNDO表空間替換現(xiàn)有的UNDO表空間,UNDO表空間數(shù)據(jù)文件的丟失導致某些事務無法回滾,數(shù)據(jù)庫的某些數(shù)據(jù)塊不一致(可以認為被邏輯損壞),但我們可以接受部分塊的損壞,恢復過程需要多次重啟數(shù)據(jù)庫實例。

如果你的數(shù)據(jù)庫還能干凈的關閉,但在正常情況下無法新建UNDO表空間,那么執(zhí)行以下的步驟:

I.A. THE DATABASE WAS CLEANLY SHUT DOWN 
--------------------------------------- 

If you are ABSOLUTELY POSITIVE that the database was cleanly shutdown, 
i.e., it was closed with either shutdown NORMAL or IMMEDIATE, then 
the simplest solution is to offline drop the missing datafile, open the 
database in restricted mode, and then drop and recreate the undo  
tablespace to which the file belonged.  DO NOT follow this procedure 
if the database was shut down ABORT or if it crashed. 

The steps are: 

1. Make sure the database was last cleanly shut down. 

   Check the alert.log file for this instance.  Go to the bottom of 
   the file and make sure the last time you shut the database down 
   you got the messages: 

        "Shutting down instance (immediate)" 

   OR

"alter database close normal  
         Completed: alter database close normal"

   This also includes the case of a clean shutdown followed by a 
   failed attempt to startup the database.  In that case, Oracle will 
   issue error messages and shut itself down abort.  For the purposes 
   of this solution, though, this counts as a clean shutdown. 

   If that is not the case, i.e., if the last time YOU shut the database 
   down it was in abort mode, or the database crashed itself, it is 
   NOT safe to proceed.  You should follow the instructions for 
   case I.B below. 

2. If using automatic UNDO_MANAGEMENT, comment out this entry from the parameter 
   file, or set it to MANUAL.  

   將UNDO_MANAGEMENT修改為MANUAL是因為UNDO表空間在自動管理模式下,如果不能成功新建回滾段(后面會DROP現(xiàn)有表空間)將導致數(shù)據(jù)庫實例宕機。

   If using rollback segments, remove all the rollback segments in the 
   tablespace to which the lost datafile belongs from the ROLLBACK_SEGMENTS 
   parameter in the init.ora file for this instance.  If you are not sure about which rollbacks are 
   in that tablespace, simply comment out the whole ROLLBACK_SEGMENTS entry. 

3. Mount the database in restricted mode. 

   SQL> STARTUP RESTRICT MOUNT 
   以RESTRICT模式啟動實例是避免在處理過程中有其他客戶端連接。

4. Offline drop the lost datafile. 

   SQL> ALTER DATABASE DATAFILE '
' OFFLINE DROP; 

5. Open the database. 

   SQL> ALTER DATABASE OPEN 

   You should receive the message "Statement processed,".  

   If instead you get ORA-604, ORA-376, and ORA-1110, it is likely the shutdown
   was not normal/immediate.  Review the rest of the options available and/or 
   contact Oracle Support Services.   

6. Drop the undo tablespace or tablespace which contains rollback segments
   to which the datafile belonged. 

   SQL> DROP TABLESPACE 
INCLUDING CONTENTS; 

7. Recreate the undo tablespace.  If using rollback segments, recreate the 
   rollback segment tablespace and all it's rollback segments.  Remember to 
   bring the rollbacks online after you create them. 

  SQL> CREATE TABLESPACE UNDOTBS2 DATAFILE 
SIZE 1G AUTOEXTEND ON NEXT 100M;

8. Edit the parameter file setting:
   UNDO_MANAGEMENT=AUTO
   UNDO_TABLESPACE=
 
  
   If using rollback segments, reinclude the rollbacks you just recreated in 
   the ROLLBACK_SEGMENTS parameter in the init.ora file for this instance. 
   As rollback segments were brought online in step #7, no need to proceed 
   with shutdown/startup as needed for undo tablespace.  All that is required
   is:

   SQL> ALTER SYSTEM DISABLE RESTRICTED SESSION; 

如果你的數(shù)據(jù)庫不能正常關閉,只需要在重啟數(shù)據(jù)庫實例之前將下面的參數(shù)加到參數(shù)文件:
_allow_resetlogs_corruption=TRUE
_offline_rollback_segments="_SYSSMU1$"
_offline_rollback_segments="_SYSSMU2$"
_offline_rollback_segments="_SYSSMU3$"
_offline_rollback_segments="_SYSSMU4$"
_offline_rollback_segments="_SYSSMU5$"
_offline_rollback_segments="_SYSSMU6$"
_offline_rollback_segments="_SYSSMU7$"
_offline_rollback_segments="_SYSSMU8$"
_offline_rollback_segments="_SYSSMU9$"
_offline_rollback_segments="_SYSSMU10$"
_corrupted_rollback_segments="_SYSSMU1$"
_corrupted_rollback_segments="_SYSSMU2$"
_corrupted_rollback_segments="_SYSSMU3$"
_corrupted_rollback_segments="_SYSSMU4$"
_corrupted_rollback_segments="_SYSSMU5$"
_corrupted_rollback_segments="_SYSSMU6$"
_corrupted_rollback_segments="_SYSSMU7$"
_corrupted_rollback_segments="_SYSSMU8$"
_corrupted_rollback_segments="_SYSSMU9$"
_corrupted_rollback_segments="_SYSSMU10$"

    rollback_segments的具體值可以從v$rollname中獲得。

    處理完成后停止數(shù)據(jù)庫實例,去掉以上參數(shù),修改好UNDO相關參數(shù)即可正常啟動數(shù)據(jù)庫實例,之后再手動處理TEMP表空間丟失的TEMP數(shù)據(jù)文件。

    雖然數(shù)據(jù)庫實例能夠正常啟動,也恢復了UNDO表空間的使用,但這并不代表不一致的塊已經(jīng)恢復,執(zhí)行某些查詢的時候可能會收到報錯,數(shù)據(jù)庫完全恢復正常后應該立即執(zhí)行一次邏輯備份+物理備份,確保數(shù)據(jù)庫的安全。


上一篇:iPhone 7都上256GB容量了,閃存價格還會漲!

下一篇:安卓手機鏡像方法

熱門閱讀

你丟失數(shù)據(jù)了嗎!

我們有能力從各種數(shù)字存儲設備中恢復您的數(shù)據(jù)

Scroll to Top