[20190314]理解TRANSPORT_CONNECT_TIMEOUT RETRY_COUNT引數在tnsnames.ora.tx

lfree發表於2019-03-14

[20190314]理解LOAD_BALANCE TRANSPORT_CONNECT_TIMEOUT RETRY_COUNT引數在tnsnames.ora.txt


--//連結:

--//以前也做過類似測試:http://blog.itpub.net/267265/viewspace-2199977/


TRANSPORT_CONNECT_TIMEOUT:


"The TRANSPORT_CONNECT_TIMEOUT parameter specifies the time, in seconds, for a client to establish a TCP connection to

the database server. The default value is 60 seconds." For more information, click here


RETRY_COUNT:


"To specify the number of times an ADDRESS list is traversed before the connection attempt is terminated." For more

information, click here         


--//實際上測試次數是RETRY_COUNT+1.

--//重複測試:


1.在/tmp目錄下建立tnsnames.ora,內容如下:


$ export TNS_ADMIN=/tmp

$ cat tnsnames.ora

CLIENT_CON =

 (DESCRIPTION =

  (LOAD_BALANCE=ON)

   (TRANSPORT_CONNECT_TIMEOUT=3)(RETRY_COUNT=2)

   (ADDRESS = (PROTOCOL = TCP)(HOST =10.10.10.10)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =11.11.11.11)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =12.12.12.12)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =13.13.13.13)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =14.14.14.14)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =15.15.15.15)(PORT = 1522))

  (CONNECT_DATA =

     (SERVER = DEDICATED)

     (SERVICE_NAME = orclgg)

   ))


2.測試:

$ export TNS_ADMIN=/tmp

$ strace -tT -f tnsping client_con 2>&1 | grep  'connect'

$ strace -tT -f tnsping client_con 2>&1 | grep  'connect'

08:58:03 connect(4, {sa_family=AF_FILE, path="/var/run/nscd/socket"...}, 110) = -1 ENOENT (No such file or directory) <0.000033>

08:58:03 connect(4, {sa_family=AF_FILE, path="/var/run/nscd/socket"...}, 110) = -1 ENOENT (No such file or directory) <0.000033>

08:58:03 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("15.15.15.15")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000052>

08:58:06 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("12.12.12.12")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000042>

08:58:09 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("14.14.14.14")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000044>

08:58:12 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("11.11.11.11")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000041>

08:58:15 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("13.13.13.13")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000041>

08:58:18 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("10.10.10.10")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000042>


08:58:21 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("12.12.12.12")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000042>

08:58:24 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("10.10.10.10")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000041>

08:58:27 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("11.11.11.11")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000041>

08:58:30 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("14.14.14.14")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000043>

08:58:33 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("13.13.13.13")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000042>

08:58:36 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("15.15.15.15")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000041>


08:58:39 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("10.10.10.10")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000044>

08:58:42 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("12.12.12.12")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000043>

08:58:45 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("15.15.15.15")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000042>

08:58:48 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("11.11.11.11")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000040>

08:58:51 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("13.13.13.13")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000045>

08:58:54 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("14.14.14.14")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000041>


--//分成3組,也就是嘗試3次.每次選擇的IP不是定義的順序(LOAD_BALANCE=ON).

--//如果連線不上,時間間隔是3秒嘗試下一個.


3.修改tnsnames.ora檔案(LOAD_BALANCE=OFF):

--//重複測試:

$ strace -tT -f tnsping client_con 2>&1 | grep -E 'connect'

09:01:46 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("10.10.10.10")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000050>

09:01:49 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("11.11.11.11")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000042>

09:01:52 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("12.12.12.12")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000042>

09:01:55 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("13.13.13.13")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000043>

09:01:58 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("14.14.14.14")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000044>

09:02:01 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("15.15.15.15")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000042>


09:02:04 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("10.10.10.10")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000042>

09:02:07 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("11.11.11.11")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000046>

09:02:10 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("12.12.12.12")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000036>

09:02:13 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("13.13.13.13")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000034>

09:02:16 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("14.14.14.14")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000036>

09:02:19 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("15.15.15.15")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000038>


09:02:22 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("10.10.10.10")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000037>

09:02:25 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("11.11.11.11")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000038>

09:02:28 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("12.12.12.12")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000037>

09:02:31 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("13.13.13.13")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000038>

09:02:34 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("14.14.14.14")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000037>

09:02:37 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("15.15.15.15")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000037>


--//可以發現嘗試順便選擇的IP是定義的順序.


4.取消TRANSPORT_CONNECT_TIMEOUT設定:

$ cat tnsnames.ora

CLIENT_CON =

 (DESCRIPTION =

  (LOAD_BALANCE=OFF)

   (RETRY_COUNT=1)

   (ADDRESS = (PROTOCOL = TCP)(HOST =10.10.10.10)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =11.11.11.11)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =12.12.12.12)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =13.13.13.13)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =14.14.14.14)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =15.15.15.15)(PORT = 1522))

  (CONNECT_DATA =

     (SERVER = DEDICATED)

     (SERVICE_NAME = orclgg)

   ))



$ strace -tT -f tnsping client_con 2>&1 | grep -E 'connect'

09:05:53 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("10.10.10.10")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000052>

09:06:53 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("11.11.11.11")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000045>

09:07:53 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("12.12.12.12")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000047>

09:08:53 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("13.13.13.13")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000057>

09:09:53 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("14.14.14.14")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000057>

09:10:53 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("15.15.15.15")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000067>


09:11:53 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("10.10.10.10")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000056>

09:12:53 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("11.11.11.11")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000051>

09:13:53 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("12.12.12.12")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000042>

09:14:54 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("13.13.13.13")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000043>

09:15:54 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("14.14.14.14")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000045>

09:16:54 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("15.15.15.15")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000043>


--//可以發現間隔是60秒,也就是預設TRANSPORT_CONNECT_TIMEOUT=60.


4.取消RETRY_COUNT設定:

$ cat tnsnames.ora

CLIENT_CON =

 (DESCRIPTION =

  (LOAD_BALANCE=OFF)

   (TRANSPORT_CONNECT_TIMEOUT=1)

   (ADDRESS = (PROTOCOL = TCP)(HOST =10.10.10.10)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =11.11.11.11)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =12.12.12.12)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =13.13.13.13)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =14.14.14.14)(PORT = 1522))

   (ADDRESS = (PROTOCOL = TCP)(HOST =15.15.15.15)(PORT = 1522))

  (CONNECT_DATA =

     (SERVER = DEDICATED)

     (SERVICE_NAME = orclgg)

   ))


$ strace -tT -f tnsping client_con 2>&1 | grep  'connect'

09:20:05 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("10.10.10.10")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000047>

09:20:06 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("11.11.11.11")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000041>

09:20:07 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("12.12.12.12")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000050>

09:20:08 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("13.13.13.13")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000042>

09:20:09 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("14.14.14.14")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000043>

09:20:10 connect(4, {sa_family=AF_INET, sin_port=htons(1522), sin_addr=inet_addr("15.15.15.15")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000042>


--//預設RETRY_COUNT=0.


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

相關文章