ITPub博客

首页 > 数据库 > Oracle > [20190314]理解TRANSPORT_CONNECT_TIMEOUT RETRY_COUNT参数在tnsnames.ora.tx

[20190314]理解TRANSPORT_CONNECT_TIMEOUT RETRY_COUNT参数在tnsnames.ora.tx

原创 Oracle 作者:lfree 时间:2019-03-14 09:18:24 0 删除 编辑

[20190314]理解LOAD_BALANCE TRANSPORT_CONNECT_TIMEOUT RETRY_COUNT参数在tnsnames.ora.txt


--//链接:https://dba010.com/2019/03/11/understanding-load_balance-parameter-in-tnsnames-ora/

--//以前也做过类似测试: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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    2353
  • 访问量
    6098200