
报送单位: 黑龙江省电力有限公司 审核人:赵威
类型:数据库、侦听
1、引言
在日常的运维工作中,数据库的运维是一个长期的工作。如何保证数据库健康的运行,是我们工作中的一个课题。
2、现象描述
业务应用程序出现间竭性连接不上数据库的情况。从主机登陆数据库,发现数据库户动正常。但查看侦听时,发现侦听hang住,不能正使工作。将侦听进程关掉,重启侦听后可正常连接数据库。但不久后,又发生上述情况。
3、处理过程
检查问题数据库监听日志无异常,alert.log警报日志报如下错误——
Mon Nov 22 09:21:09 2010
WARNING: inbound connection timed out (ORA-3136 )
Mon Nov 22 09:22:11 2010
WARNING: inbound connection timed out (ORA-3136 )
……
Tue Dec 14 17:40:41 2010
WARNING: inbound connection timed out (ORA-3136 )
Tue Dec 14 17:57:56 2010
WARNING: inbound connection timed out (ORA-3136 )
Tue Dec 14 18:00:21 2010
检查相应的sqlnet.log日志,存在如下信息——
Fatal NI connect error 12170 .
VERSION INFORMATION:
TNS for HPUX: Version 10.2.0.1.0 - Production
Oracle Bequeath NT Protocol Adapter for HPUX: Version 10.2.0.1.0 - Production
TCP/IP NT Protocol Adapter for HPUX: Version 10.2.0.1.0 - Production
Time: 29-8月 -2008 15:01:38
Tracing not turned on.
Tns error struct:
ns main err code: 12535
TNS-12535: TNS:operation timed out
ns secondary err code: 12560
nt main err code: 505
TNS-00505: Operation timed out
nt secondary err code: 238
nt OS err code: 0
Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=xx.xx.xx.xx)(PORT=492 ))
处理办法:
在数据库服务端禁用连接超时功能。
修改listener.ora中的inbound_connect_timeout参数值为0
1)进入监听管理命令窗lsnrctl
#su - oracle
> lsnrctl
2)查看inbound_connect_timeout参数:
LSNRCTL> show inbound_connect_time
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=...)(PORT=...)))
LISTENER parameter "inbound_connect_timeout" set to 60
The command completed successfully
3)如果inbound_connect_timeout参数值不为0,则可以修改为0
LSNRCTL> set inbound_connect_time 0
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=...)(PORT=...)))
LISTENER parameter "inbound_connect_timeout" set to 0
The command completed successfully
修改sqlnet.ora中的SQLNET.INBOUND_CONNECT_TIMEOUT为0
vi $ORACLE_HOME/network/admin/sqlnet.ora
SQLNET.INBOUND_CONNECT_TIMEOUT = 0
重新载入listener
#su - oracle
> lsnrctl
LSNRCTL> reload
4、原因分析
可能的原因:
●Client在default 60秒内没有完成认证
服务器收到客户端连接请求,在默认的60秒内长时间无响应,连接中断。
●DB负载太高
数据库服务器负载太高,在缺省时间内无法让更多的客户端接入,数据库报“WARNING: inbound connection timed out (ORA-3136)”错误信息
●网络攻击,例如半开连接攻击
服务器收到客户端大量无目的恶意连接请求,导致正常操作无法顺利接入数据库。通过检查sqlnet.log日志可以查看到客户端的IP地址与端口信息。
从10.2.0.1版本起oracle监听的一个功能变化,就是oracle监听在处理连接时,如果超时就会中断客户端连接。
此参数作用在于防止类似DoS攻击(恶意攻击者,通过不停的开启大量数据库连接请求,占用服务器的连接资源,使得服务器无法提供有效服务),默认超时间为60秒,老版本是0(即没有超时设置)。该参数可以通过在服务媏设置为0来禁用。
附:参考官方说明[ Note:465043.1 ]
The "WARNING: inbound connection timed out (ORA-3136)" in the alert log indicates that the client was not able to complete it's authentication within the period of time specified by parameter SQLNET.INBOUND_CONNECT_TIMEOUT.You may also witness ORA-12170 without timeout error on the database server sqlnet.log file.This entry would also have the clinet address which failed to get authenticated. Some applications or JDBC thin driver applications may not have these details.
5、经验总结
对于发现问题、解决过程需要有一个较为清晰的思路。先观察数据库本身,再观察侦听,直至发现问题。要善于借助各种日志,对数据库进行分析。及时了解ORACLE数据库各版本之间存在的差异。
6、技术人员
黑龙江省电力有限公司 苏哈江
国网三线工程师 史长松
