天天看點

DB2崩潰恢複

1.問題現象

執行個體異常當機或者非正常停止DB2執行個體,第一次資料庫連接配接慢,此類問題與執行個體類異常中執行個體崩潰Crash相關。

2.問題診斷

通過db2pd -db <db_name> -recovery驗證資料的狀态:
驗證db2diag.log中存在如下資訊:
FUNCTION: DB2 UDB, base sys utilities, sqledint, probe:30
MESSAGE : Crash Recovery is needed.
…………………………
MESSAGE : Crash recovery started. LowtranLSN 00000008DD8927E0 MinbuffLSN    00000008DD889A55      

3.恢複步驟

可以通過db2 restart db

手工出發CrashRecovery,但無法加速recovery恢複,并等待完成,觀察db2diag.log如下資訊:

FUNCTION: DB2 UDB, recovery manager, sqlpresr, probe:3170

MESSAGE : ADM1531E Crash recovery has completed successfully.

…………………….

FUNCTION: DB2 UDB, recovery manager, sqlpresr, probe:3170

MESSAGE : Crash recovery completed. Next LSN is 00000008DD946F9A

注意:如果以上crash recovery無法正常完成,可能資料庫日志控制檔案已損壞,請檢查db2diag.log資訊。

在db2_kill之前,可以執行髒頁重新整理操作:

db2pdcfg -flushbp
db2_kill      

顯示如下輸出:

State of the bufferpools:
Oldest LSN: 0000000003E80010
Newest LSN: 0000000003E901EA
Initiating background flush.
You can use "db2pdcfg -flushbp q" to monitor the progress of the flush operation.
When the oldest LSN reported by the q option is greater than the
newest LSN reported during the initial flush, then the flush has completed.