ORA-12519, TNS:no appropriate service handler found

 

ORA-12519: TNS:no appropriate service handler found 的解决

有时候连得上数据库,有时候又连不上.

可能是数据库上当前的连接数目已经超过了它能够处理的最大值.

SQL> select count ( * ) from v$process; --当前连接数
     COUNT(*)
     63
SQL> select value from v$parameter where name = ' processes ' -- 数据库允许的最大连接数
VALUE
500

修改最大连接数:
SQL> alter system set processes = 2000 scope = spfile;

重启数据库:
SQL> shutdown immediate;
SQL> startup;

-- 查看当前有哪些用户正在使用数据
SELECT osuser, a.username,cpu_time / executions / 1000000 || ' s ' , sql_fulltext,machine
from v$session a, v$sqlarea b
where a.sql_address = b.address order by cpu_time / executions desc ;

--快速删除不活动进程
set heading off
spool on
select p.SPID from v$session s,v$process p where s.paddr= p.addr and s.machine='woogle';
spool off
set serveroutput on ;
declare
v_sid number;
v_serial number;
v_sql varchar2(200) ;
CURSOR cur_session is
   select sid, serial# from v$session where machine='woogle';
begin
open cur_session ;
fetch cur_session into v_sid , v_serial ;
while cur_session%found
loop
dbms_output.put_line(v_sid||' killed!') ;
v_sql:= 'alter system kill session '||''''||v_sid||','||v_serial||'''';
execute immediate v_sql ;
fetch cur_session into v_sid , v_serial ;
end loop ;
close cur_session ;
end ;
/


Linux 下快速删除不活动进程
#!/bin/bash

tmpfile=/tmp/tmp.$$

sqlplus ' / as sysdba' << EOF

set heading off
spool on
spool $tmpfile
select p.SPID from v$session s,v$process p where s.paddr= p.addr and s.STATUS='SNIPED';
spool off
set serveroutput on ;
declare
v_sid number;
v_serial number;
v_sql varchar2(200) ;
CURSOR cur_session is
   select sid, serial# from v$session where STATUS='SNIPED';
begin
open cur_session ;
fetch cur_session into v_sid , v_serial ;
while cur_session%found
loop
dbms_output.put_line(v_sid||' killed!') ;
v_sql:= 'alter system kill session '||''''||v_sid||','||v_serial||'''';
execute immediate v_sql ;
fetch cur_session into v_sid , v_serial ;
end loop ;
close cur_session ;
end ;
/

你可能感兴趣的:(ORA-12519, TNS:no appropriate service handler found)