久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Oracle數據庫UNDO損壞后的恢復是怎樣的

142次閱讀
沒有評論

共計 5007 個字符,預計需要花費 13 分鐘才能閱讀完成。

這期內容當中丸趣 TV 小編將會給大家帶來有關 Oracle 數據庫 UNDO 損壞后的恢復是怎樣的,文章內容豐富且以專業的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

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

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

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

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

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

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 現有表空間)將導致數據庫實例宕機。

   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 full_path_file_name 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 tablespace_name 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 datafile_name SIZE 1G AUTOEXTEND ON NEXT 100M;

8. Edit the parameter file setting:
   UNDO_MANAGEMENT=AUTO
   UNDO_TABLESPACE= new undo tablespace name  
 
   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; 

如果你的數據庫不能正常關閉,只需要在重啟數據庫實例之前將下面的參數加到參數文件:
_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 中獲得。
    處理完成后停止數據庫實例,去掉以上參數,修改好 UNDO 相關參數即可正常啟動數據庫實例,之后再手動處理 TEMP 表空間丟失的 TEMP 數據文件。
    雖然數據庫實例能夠正常啟動,也恢復了 UNDO 表空間的使用,但這并不代表不一致的塊已經恢復,執行某些查詢的時候可能會收到報錯,數據庫完全恢復正常后應該立即執行一次邏輯備份 + 物理備份,確保數據庫的安全。

上述就是丸趣 TV 小編為大家分享的 Oracle 數據庫 UNDO 損壞后的恢復是怎樣的了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注丸趣 TV 行業資訊頻道。

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-18發表,共計5007字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 天镇县| 吕梁市| 微山县| 陆河县| 哈巴河县| 黄冈市| 凤冈县| 海口市| 巴彦淖尔市| 海盐县| 宣武区| 平凉市| 陇川县| 华容县| 乐清市| 花莲市| 朔州市| 剑川县| 龙南县| 天峨县| 沙湾县| 枣阳市| 德令哈市| 兰溪市| 改则县| 乐安县| 金堂县| 平阳县| 临武县| 宜昌市| 江津市| 台山市| 射洪县| 德庆县| 廉江市| 徐州市| 青海省| 阳春市| 乐陵市| 呼和浩特市| 台江县|