今天在做SOA幾個數據庫的重啟操作,其中一個數據庫在關閉過程中一直處於HANG住狀態,十幾分鍾沒有任何進展,具體操作過程如下:
一:當時的情景
SQL> shutdown immediate
--無任何返回結果
二:問題定位過程
1.查詢相關進程只有ORACLE的關鍵進程存在
ps -ef |grep ora_
soadb 4487 1 0 22:57:05 ? 0:00 ora_reco_soadbprd
soadb 4485 1 5 22:57:05 ? 0:00 ora_smon_soadbprd
soadb 4526 1 0 22:57:15 ? 0:00 ora_arc0_soadbprd
soadb 4479 1 0 22:57:04 ? 0:00 ora_dbw1_soadbprd
soadb 4483 1 0 22:57:04 ? 0:01 ora_ckpt_soadbprd
soadb 4468 1 0 22:57:02 ? 0:02 ora_pmon_soadbprd
2.查看alter日志,顯示如下:
Shutting down instance: further logons disabled
Thu Nov 14 22:04:24 2013
Stopping background process CJQ0
Thu Nov 14 22:04:24 2013
Stopping background process QMNC
Thu Nov 14 22:04:26 2013
Stopping background process MMNL
Thu Nov 14 22:04:27 2013
Stopping background process MMON
Thu Nov 14 22:04:27 2013
Shutting down instance (immediate)
License high water mark = 152
Thu Nov 14 22:04:27 2013
Stopping Job queue slave processes, flags = 7
Thu Nov 14 22:04:27 2013
Job queue slave processes stopped
Waiting for dispatcher 'D000' to shutdown
All dispatchers and shared servers shutdown
Thu Nov 14 22:04:30 2013
ALTER DATABASE CLOSE NORMAL
Thu Nov 14 22:09:34 2013
Waiting for smon to disable tx recovery.
Thu Nov 14 22:23:46 2013
MMNL absent for 1201 secs; Foregrounds taking over
3.針對紅色字體的提示,查詢官方網站,ID 1076161.6
官方描述如下:
During shutdown the SMON process is cleaning up extents and updating the data
dictionary tables with the marked free extents. As the extents are marked as
freed, they are removed from the table for used extents, UET$ and placed on the
table for free extents, FET$.
官方描述的原因是因為smon進程在清時臨時表空間數據塊和更新數據字典時造成的數據庫HANG住,原理講的很清楚,里面還有一個鏈接,一個是講述這種情況可能是一個BUG,另一個鏈接教我們診斷數據庫HANG住的具體原因。但現在的問題是,如果一直等下去,可能需要幾個小時,此次變更數據庫重啟只有半小時時間,不可能待下去,怎么辦?
4.嘗試取消shutdown immediate命令
CTRAL + C沒有任何作用,新建一個鏈接執行查詢或其它操作,會報一個錯,具體信息如下:
ORA-01089: immediate shutdown in progress - no operations are permitted
可以看到,此時什么都不允許操作,這時想找從操作系統上找到shutdown immediate進程KILL掉,后來仔細一想,這個操作可能比shutdown abort更危險,很可能造成數據庫無法啟動,在網上找到了相關資源,也沒找到辦法,此時突然想到剛學ORACLE數據庫啟動和停止時有一條命令是
startup force:中止當前數據庫的運行,並開始重新正常的啟動數據庫
startup force = shutdown abort +startup 此時也只能用它了
5.強制停止shutdown immediate
新打開一個sqlplus / as sysdba
SQL> startup force
ORACLE instance started.
Total System Global Area 3206836224 bytes
Fixed Size 2180024 bytes
Variable Size 1778388040 bytes
Database Buffers 1409286144 bytes
Redo Buffers 16982016 bytes
Database mounted.
Database opened.
此時shutdown immediate窗口停止了,數據庫恢復到可操作狀態,此時我再次用shutdown immediate命令再次正常停止數據庫,依然無法停止,沒辦法,再次執行startup force獲取數據庫控制權,選擇shutdown abort方法停止數據庫。重新啟動,很幸運,啟動成功了!(注意此操作有一定的風險,小心操作)
轉:http://blog.sina.com.cn/s/blog_61cd89f60102eeg1.html