不能连接Oracle数据库了,提示相关的错误7 m3 }: p/ p1 a4 I. ]
OERR: ORA-12519 TNS:no appropriate service handler found) C0 Q8 D5 c% a* H% f
客户端连接间歇性失败,报错ORA-12519: e% p7 B6 }# k8 H, D7 d! b
Cause: the listener could not find any available service handlers that are
\$ M/ r" f" u- O, ? appropriate for the client connection.
: ?2 f& Y0 j3 {5 F$ {7 X+ k2 V Action: run "lsnrctl services" to ensure that the instance(s) have registered
5 W% {& G! L) B# C9 p, ] with the listener, and are accepting connections. 检查lsnrctl service ,instance已经注册,状态显示ready时,可以连接。
4 @5 f: F: @" ?/ N4 t When the listener believes the current number of connections has reached maximum load,it may set the state of the service handler for an instance to "blocked" and begin refusing
( D% [4 B/ c2 G+ V$ r6 b incoming client connections with either of the following errors: ora-12519 or ora-12516
) t. z. l7 l" D$ w, w# B, S0 j 采用服务动态注册的方式,由PMON 通过SERVICE_UPDATE 来得到目前连接情况,但SERVICE_UPDATE 有时间间隔,$ s. L- k, d C* p5 P
所以,listener显示的连接数和当前实际的连接数可能不同。2 F% I5 g8 s8 U( ^
查询解决方法:
8 b# Z; F! W3 }- i 查看一下数据库现有的进程数,是否已经达到参数processes的大小。; S5 Q& E- U/ D# `' i! d$ |
1.select count(*) from v$process; 取得数据库目前的进程数。
+ p) j! y/ q" K2 U4 q; t 2.select value from v$parameter where name = 'processes'; 取得进程数的上限。+ v, h& h: L4 p0 A( j ~7 e
3.如已达到上限,修改initSID.ora中的processes的大小。
& S5 f, q$ c3 ^ 4.重新启动数据库到nomount状态下,执行create spfile from pfile; 并startup open。5 i' e6 i& @* D- {
查询数据库自启动以来最大的并发数量
1 N% o7 ]+ V( p' Y. O4 a, a 修改最大连接数:# u, |/ b. w' I, T+ E3 u2 d9 b
alter system set processes = 300 scope = spfile;+ G8 h1 R# e) ]& t" z/ |6 t
重启数据库:
8 ^. N+ r% W4 h$ V shutdown immediate;% S7 h$ @7 { g: J6 H1 i! c
startup;
' n; M3 o: F w4 i# K2 p, C --查看当前有哪些用户正在使用数据
8 p! c3 p2 }2 \" O. }! z SELECT osuser, a.username,cpu_time/executions/1000000||'s', sql_fulltext,machine- c% ~, {, X% B: g) u1 t8 D3 t6 G2 ~
from v$session a, v$sqlarea b
; d2 x) Z' ~4 w7 m# Q where a.sql_address =b.address order by cpu_time/executions desc;" j4 q& ?9 e* {& l- s, v4 v
2/ r: } Q5 K' n3 f
有的时候我们需要调整oracle数据库的最大链接数,而这个链接数的调整是在oacle下的dbs目录下init.ora文件中调整的。
. Y# d4 v4 p7 ? g$ W( f v+ k8 Z; s ORACLE的连接数(sessions)与其参数文件中的进程数(process)有关,它们的关系如下:8 s; u& n# ^2 [' d& S+ A k3 Y
sessions=(1.1*process+5)
0 u& t; Y- z( Z' K& i 但是我们增加process数时,往往数据库不能启动了。这因为我们还漏调了一个unix系统参数:它是核心参数中的semmns,这是unix系统的信号量参数。每个process会占用一个信号量。semmns调整后,需要重新启动unix操作系统,参数才能生效。不过它的大小会受制于硬件的内存或 ORACLE SGA。范围可从200——2000不等。0 c6 M5 p* ]" T4 @8 I4 d
但是,Processes的修改不仅应该调整init.ora文件中的参数,而且应该调整OS的内核参数,象 AIX,HPUX,Solaris,SCO,UNIXWare都是这样,OS的调整是需要重新启动的,而且这个参数的设置不能简单按照多少个终端要连到这个服务器上而定,最关键是考虑会有多少同时连上的session(在使用一些共享连接的中间件时,一般就不需要太大),当然还要考虑一些Oracle的后台进程,还有一些系统维护工作需要多一些连接等。
/ J* e$ c% u% O6 g 我的atmp大前置机器上对oracle调整的时候,其使用的是unixware操作系统,在做链接数调整的时候,要先对核心参数进行调整。' c+ \1 Y* O1 J
核心主要相关的参数的调整如下:0 K1 { P7 l/ Q5 W9 X
SHMMAX 1000000000" N8 }) h1 f5 j6 u. ?- S9 m1 e2 w
SHMMIN 1
6 v+ [$ b, @) s& B ~7 M4 A SHMMNI 200/ I) e2 m( N; T7 ~6 f
SHMSEG 15
1 i- H" K$ |5 F* p5 Y SEMMNI 1000
( o9 \& V& [& E. P. L- I" W$ T SEMMSL 300" U5 H7 E; f( y6 g
SEMMNS 230
. t6 K! y* w2 H# ? SEMOPM 20+ @1 _0 [" O; ?5 r/ {
其中semmni,semmns,semmsl要加大,至少要比processes大18 ; |