RAC中刪除特定instance的session

tolilong發表於2013-10-25
單例項session可以直接透過v$session和v$locked_object兩個檢視就可以kill。[@more@]

select distinct 'ALTER SYSTEM KILL SESSION '''||b.sid||', '||b.serial#||''';'
from v$locked_object a,v$session b where a.session_id=b.sid


但是這個不能刪除RAC中session


alter system kill session 的語法:

The KILL SESSION clause lets you mark a session as terminated, roll back ongoing transactions, release all session locks, and partially recover session resources. To use this clause, your instance must have the database open. Your session and the session to be terminated must be on the same instance unless you specify integer3.You must identify the session with the following values from the V$SESSION view:
alter system KILL SESSION 'integer1, integer2[, @integer3]' [IMMEDIATE]
For integer1, specify the value of the SID column.
For integer2, specify the value of the SERIAL# column.
For the optional integer3, specify the ID of the instance where the target session to be killed exists. You can find the instance ID by querying the GV$ tables.


RAC中kill session的指令碼:

select distinct 'ALTER SYSTEM KILL SESSION '''||b.sid||', '||b.serial#||',@'||b.inst_id||''';'
from gv$locked_object a,gv$session b where a.session_id=b.sid and a.inst_id=b.inst_id


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24237320/viewspace-1060989/,如需轉載,請註明出處,否則將追究法律責任。

相關文章