首页 > Linux操作系统 > Linux操作系统 > Oracle進程的快速查殺
快速杀掉Oracle的Session 的办法
有时我们需要删除用户或者 Oracle 变得越来越慢需要重启数据库时,需要采用特殊的办法快速杀掉用户的 session。
采用传统方法杀掉速度慢:
select machine,username,sid,serial# as id,status from v$session
where username is not null;
alter system kill session‘sid,serial#’; (在 sqlplus 中執行)
状态变为 killed,此时占用的操作系统资源并没有马上释放,而是由 Pmon 进程来慢慢进行清除.
快速杀掉session 的方法:
因为一个session 对应操作系统的一个进程(process),杀掉操作系统的进程之后,Oracle的Pmon 进程会迅速进行清理工作.
a、找到你要杀掉的那个session,记下sid
select machine,username,sid,serial#,status from v$session where username is not null order by machine;
b、根据sid 找到对应的spid
select pro.spid from v$session ses,v$process pro where ses.sid=sid and ses.paddr=pro.addr;
上述两步可以合并为:
select pro.spid ,ses.machine,ses.username,ses.sid,ses.serial#,ses.status from v$session ses,v$process pro where ses.sid in (select sid from v$session where username is not null) and ses.paddr = pro.addr;
最后杀掉spid 进程:
如果是Unix, 以用kill:
$kill spid
如果是Linux,可以用kill.
$kill -9 spid (注意最好在oracle 用戶下作業)
如果是Windows,需要用到SID和spid 两个值.
c:\>orakill SID spid (注意此處SID 為實例名稱,spid為系統進程).
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/14245958/viewspace-293490/ ,如需转载,请注明出处,否则将追究法律责任。