快速清理oracle会话
在日常运维过程中,我们不管是单实例还是rac,如果很多链接并发的访问导致数据库崩掉,如卡死,想快速解决问题,后面再来找原因,我个人多年工作经验将脚本进行了整理,这里发出来提供参考。
清理会话过程无非就是两块:1、系统层面 2、数据库层面
一、系统层面清理
1、1 linux系统
netstat -an |grep :1521|grep ESTABLISHED|wc -l ps -ef|grep LOCAL=NO|grep -v grep|awk '{print $2}'|xargs kill -9
ps -ef|grep LOCAL=NO|grep -v grep|awk '{print $2}'|wc -l
--上面的意思是将外部所有访问的链接全部断开
1、2 windows系统
使用processlist工具
二、数据库层面
select --'orakill orcl '||spid 'kill -9 '||spid from sys.gV_$PROCESS t,gv$session t1 where t.addr=t1.paddr and t1.Type='USER' and t1.username is not null and t1.paddr not in (select paddr from v$bgprocess);
--上面orakill 是针对windows下杀会话的命令,在cmd下执行,orcl为实例名称。
--kill -9 是针对linux的命令。
