java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:lis

原因:连接数过多,多实例需要切换实例来加大连接数,整合了一下。

sql>show user;查看当前用户

sql>show parameter instance_name;查看当前数据库实例

sql>set ORACLE_SID=实例名  --切换实例(linux为export)


SQL> select count(*) from v$process;--当前连接数

SQL> select value from v$parameter where name = 'processes' --数据库允许的最大连接数

修改最大连接数:
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 ;
/
OERR: ORA-12519 TNS:no appropriate service handler found
url:http://blog.csdn.net/wyzxg/archive/2008/03/06/2154274.aspx
2008/03/06
skate

你可能感兴趣的:(技术)