-- How to remove a "killed" session that stays for a long time(days)
-- No Responsible for the following posted script. User should test it before apply it to production
-- check the "killed" sessions
select inst_id,SID,SERIAL#,USERNAME,PADDR,LOGON_TIME,STATUS,SERVER,OSUSER
from gv$session where status='KILLED'
/
-- check sessions without processes associated
select spid,program from v$process
where program!= 'PSEUDO'
and instr(program,'(') < 1
and addr not in (select paddr from v$session)
and addr not in (select paddr from v$bgprocess)
and addr not in (select paddr from v$shared_server);
-- Find the associated PID: Match (close to the same date) the killed session(logon time) and the processes(timestamped) from above output
!ps -ef|egrep "4340|21873|8330|8332|21559|4342|4063|4338|4336|8328|17102|17098" |grep -v grep
-- Cross Check - there should have no PID associated with the killed session
SELECT p.spid oracle_dedicated_process,s.process clientpid,s.sid FROM v$process p,v$session s
WHERE p.addr = s.paddr AND s.sid= &sid
-- Cross check - there should have no SID associated with the matched PID
SELECT p.spid oracle_dedicated_process,s.sid
FROM v$process p,v$session s WHERE p.addr = s.paddr
AND p.spid=&PID;
-- Kill the PID
ps -ef|grep <pid>
kill -9 <pid>
-- The killed PID should not be shown in the following output
select spid,program from v$process
where program!= 'PSEUDO'
and addr not in (select paddr from v$session)
and addr not in (select paddr from v$bgprocess)
and addr not in (select paddr from v$shared_server);
-- One of the killed sessions(matched the same date) should be gone from the following output
select SID,OSUSER
from v$session where status='KILLED'
/
原文地址:https://blog.csdn.net/allway2
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。