一數據庫服務器執行shutdown immediate時,遇到了下面ORA錯誤,如下所示:
$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Fri Aug 5 10:56:24 2016
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Release 10.2.0.4.0 - 64bit Production
SQL> shutdown immediate;
ORA-03113: end-of-file on communication channel
SQL> exit
檢查告警日志,發現其一直停留在"Job queue slave processes stopped".退出sqlplus然後重新登錄,重新執行shutdown immediate
$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Fri Aug 5 11:03:45 2016
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected.
SQL> shutdown immediate;
ORA-24324: service handle not initialized
ORA-24323: value not allowed
ORA-01089: immediate shutdown in progress - no operations are permitted
SQL>
後面退出會話,然後登陸sqlplus,使用shutdown abort 才將數據庫關閉。處理完成後,查了一下metal link官方文檔,發現引起錯誤的原因為:
Background processes are hanging/not started correctly during the previous startup of this database.
Hence the semaphores and shared memory segments are not getting detached properly now during shutdown.
以後遇到這個問題,可以使用下面步驟處理:
1. Verify that there are no background processes owned by "oracle" , if there are kill them
$ ps -ef | grep ora_ | grep $ORACLE_SID
2. Remove shared memory and semaphores:
A) Check for shared memory and semaphores
$ ipcs -mt (if there is anything owned by oracle remove it)
$ ipcrm -m [ID] (to remove it)
B) Check and remove semaphores
$ ipcs -sbt (if there is anything owned by oracle remove it)
$ ipcrm -s [ID] (to remove it)
C) Remove sga and lk file
$ cd $ORACLE_HOME/dbs
$ rm sgadef<SID>.dbf (removing sga file)
$ORACLE_HOME/dbs/lk<sid> (removing lk... flies)
D) If database is down, try to bring up oracle one step at a time:
$ sqlplus /nolog
SQL> startup nomount pfile = ...[path]
SQL> alter database mount;
SQL> alter database open;\
Otherwise, exit current SQL*Plus session and verify the following environment variables are set.
echo $ORACLE_HOME
echo $ORACLE_SID (echo %ORACLE_SID% on Windows)
Then, Execute the following:
sqlplus / as sysdba
shutdown abort
exit
sqlplus / as sysdba
startup
如上官方資料所示, 兩種解決方案。關於第一種方案,簡單梳理如下:
1: 清理後台進程,一般找到相關進程後,使用kill命令殺掉。
2: 清理共享內存段
3: 清理信號集
注意,在RHEL 中, ipcs -sbt命令會報錯"ipcs: invalid option -- b",這個是因為Linux上的ipcs命令,不支持UNIX上的-b,所以不能照本宣科,不要使用參數b. 具體參考官方文檔ipcs man page describes invalid -b option in RHEL 5
4: 刪除 sga and lk文件。
ipcs相關資料:
ipcs 命令往標准輸出寫入一些關於活動進程間通信設施的信息。如果沒有指定任何標志,ipcs 命令用簡短格式寫入一些關於當前活動消息隊列、共享內存段、信號量、遠程隊列和本地隊列標題。
參考資料:
ORA-24324 During Startup or Shutdown (文檔 ID 794293.1)
ORA-1089 During Shutdown Immediate (文檔 ID 1014091.102)