共計 5323 個字符,預計需要花費 14 分鐘才能閱讀完成。
本篇文章給大家分享的是有關 ORA-12516 故障的解決方法,丸趣 TV 小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著丸趣 TV 小編一起來看看吧。
早上剛上班,同事告訴我數據庫連不上了,提示“ORA-12516”錯誤,我嘗試通過 PL/SQL Developer 遠程連接數據庫,果然,報錯了“ORA-12516:
TNS: 監聽程序無法找到匹配協議棧的可用句柄”;接著我通過遠程桌面登錄服務器,嘗試用 sys 用戶登錄數據庫,報了同樣的錯誤。奇怪,昨天下班時還好好的。
我上網查了一下,這個報錯一般是由于數據庫的當前會話數不足造成的,相關的參數有兩個:processes 和 sessions。我想查一下數據庫這兩個參數,但是 sys 用戶無法登陸,真是著急。后來在朋友的建議下,采取以下步驟,順利解決了這個問題。
a. 關閉 listener,禁止新的連接;
b. 殺掉 local=no 的部分或者全部進程(根據業務的重要性),殺掉幾個,保證 sys 用戶能登陸;
c. 登進去看看哪個業務出問題了,殺掉出問題的用戶進程;
d. 檢查數據庫;
e. 啟動 listener;
介紹一下我的操作環境:
操作系統:Windows Server 2008 R2
數據庫:Oracle 10g
首先,通過 lsnrctl stop 關閉監聽器,禁止新的連接,以確保第二步能夠執行成功;
第二,關閉了兩個連接數據庫的應用程序,然后嘗試用 sys 用戶登錄數據庫,登錄成功;
第三,查看了 processes 和 sessions 兩個初始化參數值,分別為 150、170,均為默認值;
點擊 (此處) 折疊或打開
SQL
SQL show parameter processes
NAME TYPE VALUE
———————————— ———– ——————————
aq_tm_processes integer 0
db_writer_processes integer 3
gcs_server_processes integer 0
job_queue_processes integer 10
log_archive_max_processes integer 2
processes integer 150
SQL show parameter sessions
NAME TYPE VALUE
———————————— ———– ——————————
java_max_sessionspace_size integer 0
java_soft_sessionspace_limit integer 0
license_max_sessions integer 0
license_sessions_warning integer 0
logmnr_max_persistent_sessions integer 1
sessions integer 170
shared_server_sessions integer
SQL
第四,通過 select sid,serial#,program,terminal from v$session; 查看當前所有會話信息,從當時的結果可以看到,有一百多條記錄,已經超過了數據庫的 session 上限;而且,除了 Oracle 自身的十幾個會話外,其余一百多個會話都是同一個 terminal。由此,找出了故障點所在(這臺設備是昨晚剛剛安裝的一臺終端)。
第五,關閉故障設備上的應用程序,再次通過 select sid,serial#,program,terminal from v$session; 查看當前所有會話信息,查詢結果顯示只剩下二十多條會話信息,考慮到 Oracle 自身的十幾個會話外和同時啟動的幾個應用程序,應該是正常的;
第六,啟動 listener,嘗試通過其他客戶端連接數據庫,一切正常,到此故障解決;
接下來,我想看一下究竟是什么原因導致了這次故障,繼續;
第七,查看報警日志,在日志中看到了大量的 Process
m000 died 報警;
點擊 (此處) 折疊或打開
Wed Apr 29 21:27:31 2015
ksvcreate: Process(m000) creation failed
Wed Apr 29 21:28:32 2015
Process m000 died, see its trace file
Wed Apr 29 21:28:32 2015
ksvcreate: Process(m000) creation failed
Wed Apr 29 21:29:33 2015
Process m000 died, see its trace file
第八,找到對應時間的 trace 文件,看到了“ORA-00020: maximum number of processes 150
exceeded Died
during process startup with error 20 (seq=5413)”語句,原來是連接數超過了閥值,數據庫無法再建立新的連接,所以報錯。
點擊 (此處) 折疊或打開
Dump file c:\\oracle\\product\\10.2.0\\admin\\hoegh\\bdump\\hoegh_ora_8032.trc
Wed Apr 29 21:28:31 2015
ORACLE V10.2.0.4.0 – 64bit Production vsnsta=0
vsnsql=14 vsnxtr=3
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Windows NT Version V6.1 Service Pack 1
CPU : 24 – type 8664, 12 Physical Cores
Process Affinity : 0x0000000000000000
Memory (Avail/Total): Ph:3339M/8181M, Ph+PgF:10815M/16361M
Instance name: hoegh
Redo thread mounted by this instance: 1
Oracle process number: 0
Windows thread id: 8032, image: ORACLE.EXE
ORA-00020: maximum number of processes 150 exceeded
Died during process startup with error 20 (seq=5413)
OPIRIP: Uncaught error 20. Error stack:
ORA-00020: maximum number of processes (150) exceeded
Dump file c:\\oracle\\product\\10.2.0\\admin\\hoegh\\bdump\\hoegh_ora_8032.trc
Thu Apr 30 00:19:05 2015
ORACLE V10.2.0.4.0 – 64bit Production vsnsta=0
vsnsql=14 vsnxtr=3
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Windows NT Version V6.1 Service Pack 1
CPU : 24 – type 8664, 12 Physical Cores
Process Affinity : 0x0000000000000000
Memory (Avail/Total): Ph:3347M/8181M, Ph+PgF:10813M/16361M
Instance name: hoegh
Redo thread mounted by this instance: 1
Oracle process number: 0
Windows thread id: 8032, image: ORACLE.EXE
ORA-00020: maximum number of processes 150 exceeded
Died during process startup with error 20 (seq=5582)
OPIRIP: Uncaught error 20. Error stack:
ORA-00020: maximum number of processes (150) exceeded
Dump file c:\\oracle\\product\\10.2.0\\admin\\hoegh\\bdump\\hoegh_ora_8032.trc
Thu Apr 30 01:27:31 2015
ORACLE V10.2.0.4.0 – 64bit Production vsnsta=0
vsnsql=14 vsnxtr=3
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Windows NT Version V6.1 Service Pack 1
CPU : 24 – type 8664, 12 Physical Cores
Process Affinity : 0x0000000000000000
Memory (Avail/Total): Ph:3350M/8181M, Ph+PgF:10812M/16361M
Instance name: hoegh
Redo thread mounted by this instance: 1
Oracle process number: 0
Windows thread id: 8032, image: ORACLE.EXE
ORA-00020: maximum number of processes 150 exceeded
Died during process startup with error 20 (seq=5650)
OPIRIP: Uncaught error 20. Error stack:
ORA-00020: maximum number of processes (150) exceeded
Dump file c:\\oracle\\product\\10.2.0\\admin\\hoegh\\bdump\\hoegh_ora_8032.trc
Thu Apr 30 09:54:12 2015
ORACLE V10.2.0.4.0 – 64bit Production vsnsta=0
vsnsql=14 vsnxtr=3
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Windows NT Version V6.1 Service Pack 1
CPU : 24 – type 8664, 12 Physical Cores
Process Affinity : 0x0000000000000000
Memory (Avail/Total): Ph:3857M/8181M, Ph+PgF:11421M/16361M
Instance name: hoegh
Redo thread mounted by this instance: 1
Oracle process number: 0
Windows thread id: 8032, image: ORACLE.EXE
至于為什么新增設備會產生大量連接,到現在還沒有搞清楚,懷疑和操作系統有關,這臺設備安裝的操作系統是 windows xp embeded 裁剪版系統,據說在安裝系統時不太順利;在故障設備上啟動應用程序,通過 select sid,serial#,program,terminal from v$session; 監控實時會話信息,會話數不斷增多,直到觸碰閥值,數據庫報錯,問題成功復現;
我們又找來另外一臺相同配置、相同操作系統的設備進行測試,沒有出現這個問題。最后,只能把這臺設備重裝系統。
下面總結一下 ORA-12516 錯誤的解決辦法:
一、一般是由于數據庫的當前會話數不滿足造成的,可以視業務需要增加 processes 和 sessions 參數的大小,這二者的關系是:sessions=(1.1*processes+5);
二、如果存在類似上述案例的惡意連接,可以按照上述步驟找到問題 session,直接 kill 相關進程。
以上就是 ORA-12516 故障的解決方法,丸趣 TV 小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注丸趣 TV 行業資訊頻道。