摘要:ora-00020_連接數達上限
SQL > show parameter processes
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
aq_tm_processes integer 0
db_writer_processes integer 2
job_queue_processes integer 0
log_archive_max_processes integer 2
processes integer 400
select count(*) from v$process;
COUNT(*)
----------
23
-------------------------------------------------------------------------------------------
當資料庫的連接數達到上限後,後續的登陸操作都會報ORA-00020錯誤,這裡給出ORA-00020錯誤的模擬及處理方法。
1.調整資料庫的processes參數到25
1)由於processes參數是靜態參數,調整時需要使用“scope=spfile”選項進行調整。
sys@ora11g> alter system set processes=25 scope=spfile;
System altered.
2)重啟資料庫使參數調整生效
sys@ora11g> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sys@ora11g> startup;
ORACLE instance started.
Total System Global Area 535662592 bytes
Fixed Size 1337720 bytes
Variable Size 398460552 bytes
Database Buffers 130023424 bytes
Redo Buffers 5840896 bytes
Database mounted.
Database opened.
3)確認調整結果
sys@ora11g> show parameter processes
NAMETYPE VALUE
--------------------------------- -------------
aq_tm_processesinteger 0
db_writer_processesinteger 1
gcs_server_processesinteger 0
global_txn_processesinteger 1
job_queue_processesinteger 1000
log_archive_max_processesinteger 4
processesinteger 25
此時資料庫的processes參數已經成功調整為25。
2.查看當前資料庫進程數
sys@ora11g> select count(*) from v$process;
COUNT(*)
----------
23
此時進程數是23。25是進程數的上限,因此次資料庫實例還可以支援一個進程連接。
3.開啟新視窗連接資料庫實例
ora11g@secdb /home/oracle$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Dec 12 21:25:30 2011
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
sys@ora11g> select count(*) from v$process;
COUNT(*)
----------
24
此時顯示成功連接到資料庫實例,進程數顯示為24。
4.再次開啟新視窗創建資料庫連接
ora11g@secdb /home/oracle$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Dec 12 21:26:37 2011
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-00020: maximum number of processes (25) exceeded
Enter user-name:
ORA-00020錯誤已經成功類比出來,原因是此時已經達到資料庫進程數的上限25。注意25表示最大的進程數,即當進程數為25時即會報錯,資料庫實例最多支援24個有效的進程。
5.處理ORA-00020錯誤
既然是由於進程數過多到時的報錯,因此我們最直接的處理方法便是手工殺掉無用的用戶連接。
1)查看資料庫後臺進程資訊
ora10g@secdb /home/oracle$ ps -ef | grep ora11g
oracle 22882 1 0 21:24 ? 00:00:00 ora_pmon_ora11g
oracle 22884 1 0 21:24 ? 00:00:00 ora_vktm_ora11g
oracle 22888 1 0 21:24 ? 00:00:00 ora_gen0_ora11g
oracle 22890 1 0 21:24 ? 00:00:00 ora_diag_ora11g
oracle 22892 1 0 21:24 ? 00:00:00 ora_dbrm_ora11g
oracle 22894 1 0 21:24 ? 00:00:00 ora_psp0_ora11g
oracle 22896 1 0 21:24 ? 00:00:00 ora_dia0_ora11g
oracle 22898 1 0 21:24 ? 00:00:00 ora_mman_ora11g
oracle 22900 1 0 21:24 ? 00:00:00 ora_dbw0_ora11g
oracle 22902 1 0 21:24 ? 00:00:00 ora_lgwr_ora11g
oracle 22904 1 0 21:24 ? 00:00:00 ora_ckpt_ora11g
oracle 22906 1 0 21:24 ? 00:00:00 ora_smon_ora11g
oracle 22908 1 0 21:24 ? 00:00:00 ora_reco_ora11g
oracle 22910 1 0 21:24 ? 00:00:00 ora_mmon_ora11g
oracle 22912 1 0 21:24 ? 00:00:00 ora_mmnl_ora11g
oracle 22914 1 0 21:24 ? 00:00:00 ora_d000_ora11g
oracle 22916 1 0 21:24 ? 00:00:00 ora_s000_ora11g
oracle 22945 22103 0 21:24 ? 00:00:00 oracleora11g (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 22947 1 0 21:24 ? 00:00:00 ora_qmnc_ora11g
oracle 22961 1 0 21:24 ? 00:00:00 ora_cjq0_ora11g
oracle 22972 1 0 21:25 ? 00:00:00 ora_q000_ora11g
oracle 22974 1 0 21:25 ? 00:00:00 ora_q001_ora11g
oracle 22993 22992 0 21:25 ? 00:00:00 oracleora11g (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 23106 23066 0 21:27 pts/6 00:00:00 grep --color ora11g
這裡顯示出兩類進程,一類是Oracle資料庫的後臺進程,另外一類是使用者連接進程。
我們可以考慮講使用者連接進程殺掉,注意Oracle資料庫後臺進程不可輕易手工殺掉。
2)殺掉使用者連接進程22945
ora10g@secdb /home/oracle$ kill -9 22945
3)嘗試重新連接資料庫
ora11g@secdb /home/oracle$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Dec 12 21:28:56 2011
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
連接成功。到此ORA-00020錯誤便處理完畢。
6.小結
本文給出了ORA-00020錯誤的類比以及簡單的處理方法。對於生產環境最有效的避免發生ORA-00020錯誤的方法便是,上線前充分評估系統需要的最大進程數,一次性設置充分。這樣便可以從根本上防止ORA-00020錯誤的發生。