db link hang的解决方法

现象:在数据库A 通过DB_LINK  对B数据库操作,长时间不返回,hang死在里面

解决方法:在数据库B上的sqlnet.ora文件里增加参数:
SQLNET.EXPIRE_TIME=10

10代表作0分钟

 

扩展:

当设置了resource_limit=true 。通过idle_time限制session idle 时间。session idle超过设置时间,状态为sniped (v$session).,然而OS下的process并不会释放,当session(user process) 再次与server process 通讯,将关闭相应的server process.

sqlnet.expire_time 的原理不一样,Oracle Server 发送包探测dead connection ,如果连接关闭,或者不再用,则关闭相应的server process.

以上两者组合使用,减少server process,防止process超过init$ORACLE_SID极限值。

DCD: Dead Connection Detection ,可以用于检测、标记僵死而没有断开会session,再由PMON进行清理,释放资源。
开启DCD,只需要在服务端的sqlnet.ora文件中添加SQLNET.EXPIRE_TIME参数,单位为分钟:

SQLNET.EXPIRE_TIME=10

如果时间达到这个值,server端就是发出一个”probe” packet 给客户端,如要客户断是正常的,这个packet就被忽略,timer重新计时;如果客户端异常中断,则server端就会收到一个消息,用以释放连接。

 

E文原文:

sqlnet.expire_time actually works on a different principle and is used to detect dead connectionsas opposed to disconnecting(actually 'sniping') a session based on idle_time which the profile accomplishes.

Sqlnet.expire_time basically instructs the Server to send a probe packet every set minutes to the client , and if it finds a terminated connection or a connection that is no longer in use, causes the associated server process to terminate on the server.
A valid database connection that is idle will respond to the probe packet causing no action on the part of the Server , whereas the resource_limit will snipe the session when idle_time is exceeded.The 'sniped' session will get disconnected when the user(or the user process) tries to communicate with the server again.
But again,as you mentioned, expire_time works globally while idle_time profile works for that user. You can use both of them to make sure that the client not only gets sniped but also gets disconnected if the user process abnormally terminates.



 

posted @ 2012-07-11 16:58  jimeper  阅读(674)  评论(0编辑  收藏  举报