20171120關於INBOUND_CONNECT_TIMEOUT設定

lfree發表於2017-11-21

[20171120]關於INBOUND_CONNECT_TIMEOUT設定.txt

--//上午翻看以前我的發的帖子,發現連結:http://www.itpub.net/thread-2066758-1-1.html
--//今天再仔細看了一下,注意看了一下別人的回覆,才發現一些細節問題,原始連結:
--//http://www.cnblogs.com/kerrycode/p/5224483.html

關於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 parameter in sqlnet.ora on the database server

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.

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命令檢視,如下所示:

--//下午我仔細看,才發現我以前的測試錯誤在那裡.我以為2個都可以透過telnet ip port的方式測試出來.理解錯誤.^_^ .
--//實際上文件已經明確說明,看文件還是不夠認真,理解還是不夠透徹.
--//測試SQLNET.INBOUND_CONNECT_TIMEOUT,需要網路連線,出現超時才會報錯.

1.測試環境:
SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

2.測試一:
--//首先不做任何設定(預設設定)
--//session 3:
$ ps -ef  | grep oracleboo[k]
--//當前沒有任何透過網路連線到資料庫.
--//開啟幾個會話:
--//session 1:
$ tail -f alert*.log

--//session 2:
$ cd /u01/app/oracle/product/11.2.0.4/dbhome_1/network/log
--//注意:監聽listener.log的目錄位置,我在監聽配置中加入DIAG_ADR_ENABLED_LISTENER=OFF.
$ tail -f sqlnet.log listener.log

$ date;sqlplus scott/xxxxx@book
Mon Nov 20 16:30:37 CST 2017
SQL*Plus: Release 11.2.0.4.0 Production on Mon Nov 20 16:30:38 2017
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
Enter user-name:
--//不做任何操作,等60秒....

--//session 3:
$ ps -ef  | grep oracleboo[k]
oracle   56566     1  0 16:34 ?        00:00:00 oraclebook (LOCAL=NO)
--//可以發現服務端開啟1個程式.

$ tail -f alert*.log
Mon Nov 20 16:31:38 2017
WARNING: inbound connection timed out (ORA-3136)

$ tail -f sqlnet.log listener.log
==> sqlnet.log <==
***********************************************************************
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: 20-NOV-2017 16:31:38
  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=192.168.100.78)(PORT=42714))

--//listener.log沒有相關輸出.
--//注意看時間,相減就是60秒.

$ ps -ef  | grep oracleboo[k]
--//沒有輸出.說明程式已經over.
--//也就是在網路連線錯誤超時的情況下,oracle要透過SQLNET.INBOUND_CONNECT_TIMEOUT引數確定超時認證時間.
--//如果透過telnet(注client ip:192.168.100.40 ) 連線測試:
# date;time telnet 192.168.100.78 1521
Mon Nov 20 16:44:12 CST 2017
Trying 192.168.100.78...
Connected to gxqyydg4 (192.168.100.78).
Escape character is '^]'.

--//session 3:
$ ps -ef  | grep oracleboo[k]
--//可以發現根本沒有相關程式.

# lsof -P -n -i | grep 192.168.100.40
tnslsnr   56702  oracle   15u  IPv4 37111676      0t0  TCP 192.168.100.78:1521->192.168.100.40:40923 (ESTABLISHED)

# ps -ef | grep 5670[2]
oracle   56702     1  0 Nov20 ?        00:00:01 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
--//程式號對於監聽程式.

# date;time telnet 192.168.100.78 1521
Tue Nov 21 08:41:12 CST 2017
Trying 192.168.100.78...
Connected to gxqyydg4 (192.168.100.78).
Escape character is '^]'.
Connection closed by foreign host.
real    1m0.106s
user    0m0.001s
sys     0m0.001s

--//你可以發現在伺服器還沒有開啟伺服器程式,僅僅存在一個網路連線.而這個時候實際上監聽配置inbound_connect_timeout_監聽器名起作
--//用.只不過預設設定是60秒.
--//而前面sqlplus scott/xxxxx@book,既開啟網路連線,有開啟服務端程式.2者測試就很容易理解了.
--//理解這些,後面的測試就很容易理解.

--//session 2:
$ tail -f sqlnet.log listener.log
==> listener.log <==
21-NOV-2017 08:39:22 * service_update * book * 0
21-NOV-2017 08:42:12 * <unknown connect data> * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.40)(PORT=40923)) * 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

--//注意看下劃線內容,sid=<unknown sid>,<unknown connect data>,埠號PORT=40923也能對上.
--//sqlnet.log沒有相關輸出.

--//也就是在監聽配置listener.ora中的inbound_connect_timeout_監聽器名是使用者連線監聽時的超時限制.
--//                sqlnet.ora中SQLNET.INBOUND_CONNECT_TIMEOUT是等待使用者認證超時的時間(注已經透過網路連線).

--//繼續做一個測試說明問題(注:使用本地連線.不做任何操作)
$ date;sqlplus scott/xxxxx
Mon Nov 20 17:07:08 CST 2017
SQL*Plus: Release 11.2.0.4.0 Production on Mon Nov 20 17:07:08 2017
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
Enter user-name:

$ ps -ef  | grep oracleboo[k]
oracle   61056 61055  0 08:45 ?        00:00:00 oraclebook (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))

# lsof -P -n -i | grep 6105[56]
--//注意前面的連線不同,沒有透過網路連線.

$ sleep 60
$ ps -ef  | grep oracleboo[k]                                                              |
oracle   61056 61055  0 08:45 ?        00:00:00 oraclebook (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))

--//你可以發現這樣的程式不會kill掉.也就是不透過網路這個引數不會生效.
--//理解以上測試就明白,實際上2個引數對應是不同的設定,一個針對監聽,一個針對使用者認證.

3.測試二:
--//修改sqlnet.ora加入:
SQLNET.INBOUND_CONNECT_TIMEOUT=30

--//修改listener.ora加入,並且重啟監聽:
INBOUND_CONNECT_TIMEOUT_LISTENER=10

$ lsnrctl stop ;sleep 1;lsnrctl start

# date;time telnet 192.168.100.78 1521
Tue Nov 21 08:52:52 CST 2017
Trying 192.168.100.78...
Connected to gxqyydg4 (192.168.100.78).
Escape character is '^]'.
Connection closed by foreign host.

real    0m10.015s
user    0m0.002s
sys     0m0.000s
--//使用telnet測試,測試是listener.ora設定引數INBOUND_CONNECT_TIMEOUT_LISTENER=10.

$ date;sqlplus scott/xxxxx@book
Tue Nov 21 08:54:29 CST 2017
SQL*Plus: Release 11.2.0.4.0 Production on Tue Nov 21 08:54:29 2017
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
Enter user-name:

--//alter.log輸出:
==> sqlnet.log <==
Tue Nov 21 08:54:59 2017
WARNING: inbound connection timed out (ORA-3136)

--//sqlnet.log輸出:
==> sqlnet.log <==
***********************************************************************
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-NOV-2017 08:54:59
  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=192.168.100.78)(PORT=54593))

--//時間相減就是30秒.說明這樣測試網路連線的使用者認證.
--//其它可以參考連結測試http://www.cnblogs.com/kerrycode/p/5224483.html,不再重複了.

總結:
我主要犯了一個概念上錯誤,認為這個引數INBOUND_CONNECT_TIMEOUT設定針對的超時認證是一樣的東西,實際上2者存在不同.
一個表示等待使用者認證超時的時間,一個表示等待使用者連線請求超時的時間.
講的通俗一點,一個針對監聽,一個針對使用者認證(網路連線已經確立).
另外一個文件看別人的文件還是跟認真一點,這樣的錯誤就能很快發現.總之自己還是存在一些概念的混淆混亂...
我不知道還有什麼方法認證這些引數測試!!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2147529/,如需轉載,請註明出處,否則將追究法律責任。

相關文章