oracle连接数爆满,手动停止查询进程
数据库服务器负载突然暴增,连接进程爆满,大量重复的大表查询或者死锁导致,重启数据库和应用无效,最好的方法是用命令停止查询进程,并防止新的查询进入启动。
查询所有进程
select sess.sid,
sess.serial#,
lo.oracle_username,
lo.os_user_name,
ao.object_name,
lo.locked_mode
from v$locked_object lo,
dba_objects ao,
v$session sess
where ao.object_id = lo.object_id and lo.session_id = sess.sid;
挑选需要删除的进程 sid 和serial#
以下命令杀掉
alter system kill session '35, 27113';
35 sid
27113 serial#
批量处理的方式是,
select 'alter system kill session''' || sid || ',' || serial# || ''' immediate;'
from v$locked_object lo,dba_objects ao,
v$session sess
where ao.object_id = lo.object_id and lo.session_id = sess.sid;
批量处理死锁的命令
select 'alter system kill session''' || sid || ',' || serial# || ''' immediate;' from v$session t1,v$locked_object t2 where t1.sid = t2.SESSION_ID;