但是此命令釋放資源極為緩慢,具體可以參考:Oracle中Kill session的研究.
為了更快速的釋放資源,通常我們使用如下步驟來Kill進程:
1.首先在操作系統(tǒng)級kill進程
2.在數(shù)據(jù)庫內(nèi)部kill session
這樣通??梢钥焖僦兄惯M程,釋放資源。
今天就遇到這樣一個案例,其他朋友在數(shù)據(jù)庫里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對應(yīng)的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> !
在操作系統(tǒng)級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
再次在數(shù)據(jù)庫中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
此時該進程被迅速清除。
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com