您好,登錄后才能下訂單哦!
這期內容當中小編將會給大家帶來有關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表空間的使用,但這并不代表不一致的塊已經恢復,執行某些查詢的時候可能會收到報錯,數據庫完全恢復正常后應該立即執行一次邏輯備份+物理備份,確保數據庫的安全。
上述就是小編為大家分享的Oracle數據庫UNDO損壞后的恢復是怎樣的了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。