(转)oracle killed会话不释放的问题
2012-07-13 11:18
357 查看
原文连接: http://www.2cto.com/database/201204/127239.html
一般情况下,在杀一个会话的时候,直接执行alter system kill session ‘sid,serial#’;
Administrator's Guide说,当session是active的时候,alter system kill session 只是将session标识为killed
或者pseudo状态,并不会释放session持有的资源,所以我们在执行完alter system kill session 后,看会话还
是一直存在。
![](http://www.2cto.com/uploadfile/2012/0412/20120412032021887.jpg)
这种情况下可以使用 immediate选项,强制立即Kill会话,如下:
SQL> alter system kill session '3964,51752' immediate;
SQL Language Reference www.2cto.com (http://docs.oracle.com/cd/B28359_01/server.111/b28286/toc.htm#BEGIN)
里对Immediate的解释是:IMMEDIATE Specify IMMEDIATE to instruct Oracle
Database to roll back ongoing transactions, release all session locks, recover the entire session state,
and return control to you immediately.
另外我们也可以使用alter system disconnect session
The POST_TRANSACTION setting allows ongoing transactions to complete before the session is disconnected.
If the session has no ongoing transactions, then this clause has the same effect described for as KILL SESSION.
The IMMEDIATE setting disconnects the session and recovers the entire session state immediately, without
waiting for ongoing transactions to complete.
If you also specify POST_TRANSACTION and the session has ongoing transactions, then the IMMEDIATE keyword is ignored.
If you do not specify POST_TRANSACTION, or you specify POST_TRANSACTION but the session has no ongoing transactions, www.2cto.com
then this clause has the same effect as described for KILL SESSION IMMEDIATE.
![](http://www.2cto.com/uploadfile/2012/0412/20120412032044418.jpg)
ORACLE建议的DCD解决方法
修改sqlnet.ora文件,新增expire_time=x(单位是分钟)
通过ALTER PROFILE DEFAULT LIMIT IDLE_TIME x; 命令修改,重启后生效。
通过OS杀进程终止会话
1 SELECT spid, osuser, s.program, schemaname
2 FROM gv$process p, gv$session s
3 WHERE p.addr = s.paddr;
1.UNIX
kill -9 5745
ps -ef | grep pmon_$ORACLE_SID | awk '{print $2}' | xargs kill –9 #kill 一批会话
2. WINDOWS
orakill <instance_name> <spid>
如果会话已经在DB里killed,上面的SQL已经查不出spid,可以用下面的SQL查出SPID
1 select addr, pid, spid
2 FROM v$process p
3 where addr in (select p.addr
4 from v$process p
5 where pid <> 1
6 minus www.2cto.com
7 select s.paddr from v$session s)
作者 DB&*NIX
一般情况下,在杀一个会话的时候,直接执行alter system kill session ‘sid,serial#’;
Administrator's Guide说,当session是active的时候,alter system kill session 只是将session标识为killed
或者pseudo状态,并不会释放session持有的资源,所以我们在执行完alter system kill session 后,看会话还
是一直存在。
![](http://www.2cto.com/uploadfile/2012/0412/20120412032021887.jpg)
这种情况下可以使用 immediate选项,强制立即Kill会话,如下:
SQL> alter system kill session '3964,51752' immediate;
SQL Language Reference www.2cto.com (http://docs.oracle.com/cd/B28359_01/server.111/b28286/toc.htm#BEGIN)
里对Immediate的解释是:IMMEDIATE Specify IMMEDIATE to instruct Oracle
Database to roll back ongoing transactions, release all session locks, recover the entire session state,
and return control to you immediately.
另外我们也可以使用alter system disconnect session
The POST_TRANSACTION setting allows ongoing transactions to complete before the session is disconnected.
If the session has no ongoing transactions, then this clause has the same effect described for as KILL SESSION.
The IMMEDIATE setting disconnects the session and recovers the entire session state immediately, without
waiting for ongoing transactions to complete.
If you also specify POST_TRANSACTION and the session has ongoing transactions, then the IMMEDIATE keyword is ignored.
If you do not specify POST_TRANSACTION, or you specify POST_TRANSACTION but the session has no ongoing transactions, www.2cto.com
then this clause has the same effect as described for KILL SESSION IMMEDIATE.
![](http://www.2cto.com/uploadfile/2012/0412/20120412032044418.jpg)
ORACLE建议的DCD解决方法
修改sqlnet.ora文件,新增expire_time=x(单位是分钟)
通过ALTER PROFILE DEFAULT LIMIT IDLE_TIME x; 命令修改,重启后生效。
通过OS杀进程终止会话
1 SELECT spid, osuser, s.program, schemaname
2 FROM gv$process p, gv$session s
3 WHERE p.addr = s.paddr;
1.UNIX
kill -9 5745
ps -ef | grep pmon_$ORACLE_SID | awk '{print $2}' | xargs kill –9 #kill 一批会话
2. WINDOWS
orakill <instance_name> <spid>
如果会话已经在DB里killed,上面的SQL已经查不出spid,可以用下面的SQL查出SPID
1 select addr, pid, spid
2 FROM v$process p
3 where addr in (select p.addr
4 from v$process p
5 where pid <> 1
6 minus www.2cto.com
7 select s.paddr from v$session s)
作者 DB&*NIX
相关文章推荐
- oracle killed会话不释放的问题。
- Oracle小知识- Oracle KILLED会话的释放
- ORA-00031: 标记要删去的会话,显示killed,但是资源不释放
- Oracle错误:动态执行表不可访问,本会话自动统计被禁止,关闭自动统计之后的问题
- ORACLE关于DELETE后空间不释放问题
- 使用Oracle 10g中的等待界面诊断性能问题(查询会话等待,查询慢的现象)
- 关于Oracle错误:动态执行表不可访问,本会话自动统计被禁止,关闭自动统计之后的问题
- Oracle错误:动态执行表不可访问,本会话自动统计被禁止,关闭自动统计之后的问题
- oracle killed会话不释放的问题
- oracle中的锁表相关的操作,session会话的释放
- 解决Oracle RMAN删除归档日志不释放问题的方法
- oracle杀回话不释放的问题
- 定时任务起的java进程没有释放导致oracle的问题not availavle & out of memory
- proc oracle 连接释放不了的问题
- Oracle错误:动态执行表不可访问,本会话自动统计被禁止,关闭自动统计之后的问题
- Hibernate + Oracle + C3P0 连接池无没释放问题,暂用proxool配置替代
- 关于内存泄漏的问题---哪些变量需要释放
- (转)为了解决oracle10.2.0.4上EM无法启动的BUG问题,打path 8350262补丁办法
- 解决比较Oracle中CLOB字段问题