来源:网海拾贝
很多时辰因为异常或顺序错误解招致一般历程占用少量系统本钱,需求完毕这些历程,常日可以运用以下呼吁Kill历程:
alter system kill session 'sid,serial#';
可是此呼吁开释本钱极为痴钝,细致可以参考:Oracle中Kill session的钻研.
为了更快速的开释本钱,常日我们运用如下措施来Kill历程:
1.首先在操纵系统级kill历程
2.在数据库外部kill session
如许常日可以快速中止历程,开释本钱。
今天就遇到如许一个案例,其他同伙在数据库里kill session,可是长光阴仍无成效:
[oracle@danaly ~] $ sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Oct 27 11:09:50 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
SQL> select sid,username,status from v $session;
SID USERNAME STATUS
---------- ------------------------------ --------
....
154 SCOTT KILLED
...
30 rows selected.
那按照我前面提到的措施,首先盘问掉掉该session对应的OS历程号:
SQL> select 'kill -9 '||spid from v $process where addr = (select paddr from v $session where sid=&sid);
Enter value for sid: 154
old 1: select 'kill -9 '||spid from v $process where addr = (select paddr from v $session where sid=&sid)
new 1: select 'kill -9 '||spid from v $process where addr = (select paddr from v $session where sid=154)
'KILL-9'||SPID
--------------------
kill -9 22702
SQL> !
在操纵系统级kill该历程:
[oracle@danaly ~] $ ps -ef|grep 22702
oracle 22702 1 0 Oct25 ? 00:00:02 oracledanaly (LOCAL=NO)
oracle 12082 12063 0 11:12 pts/1 00:00:00 grep 22702
[oracle@danaly ~] $ kill -9 22702
[oracle@danaly ~] $ ps -ef|grep 22702
oracle 12088 12063 0 11:12 pts/1 00:00:00 grep 22702
[oracle@danaly ~] $ exit
exit
SQL> select sid,username,status from v $session;
SID USERNAME STATUS
---------- ------------------------------ --------
...
154 SCOTT KILLED
...
30 rows selected.
SQL> select sid,serial#,username from v $session where sid=154;
SID SERIAL# USERNAME
---------- ---------- ------------------------------
154 56090 SCOTT
再次在数据库中kill该session,并指定immediate选项:
SQL> alter system kill session '154,56090' immediate;
System altered.
SQL> select sid,serial#,username from v $session where sid=154;
no rows selected
此时该历程被迅速覆灭。
版权声明:
原创作品,容许转载,转载时请务必以超链接情势标明文章 原始来由 、作者信息和本声明。不然将究查法令责任。