ORA-12516故障解決

來源:互聯網
上載者:User

ORA-12516故障解決

早上剛上班,同事告訴我資料庫連不上了,提示“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相關進程。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.