mysql 僵尸链接_使用 SQLNET.EXPIRE_TIME 清除僵死连接

数据库连接的客户端异常断开后,其占有的相应并没有被释放,如从v$session视图中依旧可以看到对应的session处于inactive,且对应

数据库连接的客户端异常断开后,其占有的相应并没有被释放,,如从v$session视图中依旧可以看到对应的session处于inactive,且对应的服务器进程也没有释放,导致资源长时间地被占用,对于这种情形开该如何处理呢?SQLNET.EXPIRE_TIME对于这个问题我们提供了解决方案,专门用于清理那些异常断开的情形,如网络异常中断,客户端异常掉电,异常重启等。本文描述了设置SQLNET.EXPIRE_TIME参数以及演示死连接以及资源被释放的情形。

1、理解SQLNET.EXPIRE_TIME参数

Use parameter SQLNET.EXPIRE_TIME to specify a the time interval, in minutes, to send a probe to verify that client/server

connections are active.

Setting a value greater than 0 ensures that connections are not left open indefinitely, due to an abnormal client termination.

If the probe finds a terminated connection, or a connection that is no longer in use, it returns an error, causing the

server process to exit.

This parameter is primarily intended for the database server,which typically handles multiple connections at any one time.

通过设定参数为非零值(分钟)来发送探测包以检查客户端的异常断开。一旦探测包找到了异常的连接将返回错误,清除对应的server process

下面是参数使用的一些限制。(缺省值为0,最小值0,建议值10。SQLNET.EXPIRE_TIME=10)

Limitations on using this terminated connection detection feature are:

It is not allowed on bequeathed connections.

Though very small, a probe packet generates additional traffic that may downgrade network performance.

Depending on which operating system is in use, the server may need to perform additional processing to distinguish

the connection probing event from other events that occur. This can also result in degraded network performance.

2、Dead Connection Detection (DCD)与Inactive Sessions

Dead connections:

These are previously valid connections with the database but the connection between the client and server processes has

terminated abnormally.

Examples of a dead connection:

- A user reboots/turns-off their machine without logging off or disconnecting from the database.

- A network problem prevents communication between the client and the server.

In these cases, the shadow process running on the server and the session in the database may not terminate.

Implemented by

* adding SQLNET.EXPIRE_TIME = to the sqlnet.ora file

With DCD is enabled, the Server-side process sends a small 10-byte packet to the client process after the duration of

the time interval specified in minutes by the SQLNET.EXPIRE_TIME parameter.

If the client side connection is still connected and responsive, the client sends a response packet back to the database

server, resetting the timer..and another packet will be sent when next interval expires (assuming no other activity on

the connection).

If the client fails to respond to the DCD probe packet

* the Server side process is marked as a dead connection and

* PMON performs the clean up of the database processes / resources

* The client OS processes are terminated

NOTE: SQLNET.RECV_TIMEOUT can be set on the SERVER side sqlnet.ora file. This will set a timeout for the server process

to wait for data from the client process.

Inactive Sessions:

These are sessions that remain connected to the database with a status in v$session of INACTIVE.

Example of an INACTIVE session:

- A user starts a program/session, then leaves it running and idle for an extended period of time.

3、配置SQLNET.EXPIRE_TIME

#对于SQLNET.EXPIRE_TIME的配置,需要修改sqlnet.ora,然后添加SQLNET.EXPIRE_TIME项

[Oracle@orasrv admin]$ more sqlnet.ora

sqlnet.expire_time = 1 #仅仅需要配置此项,后面的各项仅仅是为了生成跟踪日志,可省略

TRACE_LEVEL_SERVER = 16

TRACE_FILE_SERVER = SERVER

TRACE_DIRECTORY_SERVER= /u01/app/oracle/network/trace

TRACE_TIMESTAMP_ SERVER = ON

TRACE_UNIQUE_SERVER = ON

DIAG_ADR_ENABLED=OFF

logo.gif

f68f2add0b68e4f9810432fce46917b7.png

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值