INBOUND_CONNECT_TIMEOUT与SQLNET.INBOUND_CONNECT_TIMEOUT

参数解读

客户端先连接listener,然后listener fork出一个server进程,然后进行登录验证。
连接不是说连接成功了,而是客户端先和监听建立了连接,监听然后鉴权,密码对了才给你连接到数据库。简单的过程如下:
在这里插入图片描述
具体这两个参数起作用的阶段不一样:
关于sqlnet.ora的参数SQLNET.INBOUND_CONNECT_TIMEOUT,它表示等待用户认证超时的时间,单位是秒,缺省值是60秒,如果用户认证超时了,服务器日志alert.log显示出错信息"WARNING: inbound connection timed out (ORA-3136)",sqlnet.log里面出现TNS-12535: TNS:operation timed out错误信息。

关于listener.ora的参数inbound_connect_timeout_监听器名,它表示等待用户连接请求超时的时间,单位是秒,缺省值是60秒,如果连接请求超时了,监听器日志listener.log显示出错信息"TNS-12525: TNS:listener has not received client’s request in time allowed"。

在这里插入图片描述

其中sqlnet.ora里面的参数为SQLNET.INBOUND_CONNECT_TIMEOUT, listener.ora里面的参数设置为INBOUND_CONNECT_TIMEOUT_listener_name ,其中根据监听名字来替换listener_name。官方文档关于两者的介绍如下所示:

SQLNET.INBOUND_CONNECT_TIMEOUT
Purpose

To specify the time, in seconds, for a client to connect with the database server and provide the necessary authentication information.

If the client fails to establish a connection and complete authentication in the time specified, then the database server terminates the connection. In addition, the database server logs the IP address of the client and an ORA-12170: TNS:Connect timeout occurred error message to the sqlnet.log file. The client receives either an ORA-12547: TNS:lost contact or an ORA-12637: Packet receive failed error message.

The default value of this parameter is appropriate for typical usage scenarios. However, if you need to explicitly set a different value, then Oracle recommends setting this parameter in combination with the INBOUND_CONNECT_TIMEOUT_listener_name parameter in the listener.ora file. When specifying the values for these parameters, note the following recommendations:

•Set both parameters to an initial low value.

•Set the value of the INBOUND_CONNECT_TIMEOUT_listener_name parameter to a lower value than the SQLNET.INBOUND_CONNECT_TIMEOUT parameter.

For example, you can set INBOUND_CONNECT_TIMEOUT_listener_name to 2 seconds and SQLNET.INBOUND_CONNECT_TIMEOUT parameter to 3 seconds. If clients are unable to complete connections within the specified time due to system or network delays that are normal for the particular environment, then increment the time as needed.

Default

60 seconds

Example

SQLNET.INBOUND_CONNECT_TIMEOUT=3
See Also:

•“Control Parameters” for additional information about INBOUND_CONNECT_TIMEOUT_listener_name

•Oracle Net Services Administrator’s Guide for additional information about configuring these parameters

INBOUND_CONNECT_TIMEOUT_listener_name in listener.ora

Specify the time, in seconds, for the client to complete its connect request to the listener after the network connection had been established.

If the listener does not receive the client request in the time specified, then it terminates the connection. In addition, the listener logs the IP address of the client and an ORA-12525: TNS:listener has not received client’s request in time allowed error message to the listener.log file

一个表示等待用户认证超时的时间,一个表示等待用户连接请求超时的时间.

测试

查看inbound_connect_timeout值

1:查看SQLNET.INBOUND_CONNECT_TIMEOUT的设置值,一般进入$ORACLE_HOME/network/admin下,查看sqlnet.ora参数文件即可。

2:查看监听INBOUND_CONNECT_TIMEOUT参数,可以查看listener.ora参数文件。但是有时候,例如默认情况,参数文件里面没有设置这个参数,或是有些动态监听没有配置listener.ora,那么可以使用lsnrctl命令查看,如下所示:

[oracle@oracle11g admin]$ lsnrctl       

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 21-DEC-2020 16:30:00

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> show 
The following operations are available after show
An asterisk (*) denotes a modifier or extended command:

rawmode                              displaymode                          
rules                                trc_file                             
trc_directory                        trc_level                            
log_file                             log_directory                        
log_status                           current_listener                     
inbound_connect_timeout              startup_waittime                     
snmp_visible                         save_config_on_stop                  
dynamic_registration                 enable_global_dynamic_endpoint       
oracle_home                          pid                                  
connection_rate_limit                valid_node_checking_registration     
registration_invited_nodes           registration_excluded_nodes          

LSNRCTL> show inbound_connect_timeout
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
LISTENER parameter "inbound_connect_timeout" set to 60
The command completed successfully

oracle默认为60s

SQLNET.INBOUND_CONNECT_TIMEOUT

我们首先设置SQLNET.INBOUND_CONNECT_TIMEOUT为10秒,
[oracle@oracle11g admin]$ cat sqlnet.ora
SQLNET.INBOUND_CONNECT_TIMEOUT=10
直接编辑sqlnet.ora文件,不用重启,直接生效。

模拟输错密码,认证失败

[oracle@11gasm admin]$ sqlplus system/or@zhuo

SQL*Plus: Release 11.2.0.4.0 Production on Mon Dec 21 15:50:22 2020

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name:

listener.log立马会有如下显示:

Mon Dec 21 15:51:07 2020
21-DEC-2020 15:51:07 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=zhuo)(CID=(PROGRAM=sqlplus@11gasm)(HOST=11gasm)(USER=oracle))) * (ADDRESS=(PROTOCOL=tcp)(HOST=10.1.11.12)(PORT=24635)) * establish * zhuo * 0

监听日志显示,客户端和监听的连接已经建立(establish),连接成功。

当10秒后。
alert日志

***********************************************************************

Fatal NI connect error 12170.

  VERSION INFORMATION:
        TNS for Linux: Version 11.2.0.4.0 - Production
        Oracle Bequeath NT Protocol Adapter for Linux: Version 11.2.0.4.0 - Production
        TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.4.0 - Production
  Time: 21-DEC-2020 15:51:17
  Tracing not turned on.
  Tns error struct:
    ns main err code: 12535
    
TNS-12535: TNS:operation timed out
    ns secondary err code: 12606
    nt main err code: 0
    nt secondary err code: 0
    nt OS err code: 0
  Client address: (ADDRESS=(PROTOCOL=tcp)(**HOST=10.1.11.12**)(PORT=24635))
**WARNING: inbound connection timed out (ORA-3136)**

在alert里面就能看到新增了一条关于TNS-12535的错误记录,其中10.1.11.12是我客户端的IP地址。
而且会看到WARNING: inbound connection timed out (ORA-3136)错误。有意思的是,监听日志里面你不会看到任何错误信息。

INBOUND_CONNECT_TIMEOUT_listener_name

这个参数可以通过lsnrctl命令设置,如下所示,当然最简单的还是设置listener.ora参数文件。在监听配置文件里面,必须重启生效
设置listener的连接超时时间为5:
[oracle@oracle11g admin]$ cat listener.ora
INBOUND_CONNECT_TIMEOUT_LISTENER=5

此时我们用telnet来模拟用户连接请求超时的时间,如下所示,当超过20秒,就会自动退出

[oracle@11gasm admin]$ time telnet 10.1.11.8 1521
Trying 10.1.11.8…
Connected to 10.1.11.8.
Escape character is ‘^]’.
Connection closed by foreign host.

real 1m0.034s —连接用了1s,前面的设置没生效
user 0m0.001s
sys 0m0.000s

listener.log日志报错如下:

Mon Dec 21 16:42:05 2020
21-DEC-2020 16:42:05 * <unknown connect data> * (ADDRESS=(PROTOCOL=tcp)(HOST=10.1.11.12)(PORT=25836)) * establish * <unknown sid> * 12525
TNS-12525: TNS:listener has not received client's request in time allowed
 TNS-12535: TNS:operation timed out
  TNS-12606: TNS: Application timeout occurred

alter日志里面没有报错。

我们接下来重启下监听:

[oracle@oracle11g admin]$ lsnrctl stop
[oracle@oracle11g admin]$ lsnrctl start
[oracle@oracle11g admin]$ lsnrctl

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 21-DEC-2020 16:45:46

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> show
The following operations are available after show
An asterisk (*) denotes a modifier or extended command:

rawmode                              displaymode                          
rules                                trc_file                             
trc_directory                        trc_level                            
log_file                             log_directory                        
log_status                           current_listener                     
inbound_connect_timeout              startup_waittime                     
snmp_visible                         save_config_on_stop                  
dynamic_registration                 enable_global_dynamic_endpoint       
oracle_home                          pid                                  
connection_rate_limit                valid_node_checking_registration     
registration_invited_nodes           registration_excluded_nodes          

LSNRCTL> show inbound_connect_timeout
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
LISTENER parameter "inbound_connect_timeout" set to 5
The command completed successfully

看到已经生成为5s了。再次测试:
[oracle@11gasm admin]$ time telnet 10.1.11.8 1521
Trying 10.1.11.8…
Connected to 10.1.11.8.
Escape character is ‘^]’.
Connection closed by foreign host.

real 0m5.003s --已经生效,5s连接断开
user 0m0.000s
sys 0m0.000s

listener报错如下:

Mon Dec 21 16:46:46 2020
21-DEC-2020 16:46:46 * <unknown connect data> * (ADDRESS=(PROTOCOL=tcp)(HOST=10.1.11.12)(PORT=25972)) * establish * <unknown sid> * 12525
TNS-12525: TNS:listener has not received client's request in time allowed
 TNS-12535: TNS:operation timed out
  TNS-12606: TNS: Application timeout occurred

此时在listener.log里面,你就能看到TNS-12525的错误
格式为:

TIMESTAMP * CONNECT DATA [* PROTOCOL INFO] * EVENT [* SID] * RETURN CODE

总结

在这里插入图片描述

参考:故障排除指南 ORA-3136:WARNING Inbound Connection Timed Out (Doc ID 2331569.1)
Description of Parameter SQLNET.INBOUND_CONNECT_TIMEOUT (Doc ID 274303.1)
Troubleshooting ORA-3136 Connection Timeouts Errors - Database Diagnostics (Doc ID 730066.1)
http://www.killdb.com/2020/03/18/about-ora-3136/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值