[20180129]测量网络断开时间.txt
--//我们分院与总院使用电信网络,网络链路如果一定时间空闲,就自动断开,我一直非常想了解准确的断开时间.
--//手工测试看看,主要目的是可以设置tcp_keepalive*参数或者SQLNET.EXPIRE_TIME参数.
1.修改相关设置:
# echo /proc/sys/net/ipv4/tcp_keepalive* | xargs -n 1 strings -1 -f
/proc/sys/net/ipv4/tcp_keepalive_intvl: 10
/proc/sys/net/ipv4/tcp_keepalive_probes: 4
/proc/sys/net/ipv4/tcp_keepalive_time: 7200
--//修改 /etc/sysctl.conf:
net.ipv4.tcp_keepalive_time = 7200
--//执行sysctl -p 生效.
# sysctl -p
--//注解$ORACLE_HOME/network/admin/sqlnet.ora
# grep -i SQLNET.EXPIRE_TIME sqlnet.ora
#SQLNET.EXPIRE_TIME = 1
--//建立测试脚本aa.txt与bb.txt在客户端:
cat aa.txt
select sysdate from dual;
host sleep &&1
select sysdate from dual;
cat bb.txt
@@ aa.txt 540
@@ aa.txt 600
@@ aa.txt 660
@@ aa.txt 720
@@ aa.txt 780
@@ aa.txt 840
@@ aa.txt 900
@@ aa.txt 960
@@ aa.txt 1020
@@ aa.txt 1080
--//最佳的方式是使用二分法,有点懒...^_^.
2.测试:
--//client 登录执行bb.txt脚本.server端打开tcpdump 监测网络情况:
# tcpdump -i bond1 host 192.168.98.6 and port 1521 -nn -vv
...
xxxx> @ bb.txt
...
SYSDATE
-------------------
2018-01-29 14:59:31
SYSDATE
-------------------
2018-01-29 15:09:31
SYSDATE
-------------------
2018-01-29 15:09:31
select sysdate from dual
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 20162
Session ID: 258 Serial number: 44121
--//600秒OK,660秒无法通过.
--//修改bb.txt如下,继续测试:
@@ aa.txt 610
@@ aa.txt 620
@@ aa.txt 630
@@ aa.txt 640
@@ aa.txt 650
@@ aa.txt 660
xxxx> @ bb.txt
SYSDATE
-------------------
2018-01-29 15:42:10
select sysdate from dual
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 18919
Session ID: 110 Serial number: 52705
--//测试大约600秒.精确定位看看.
@@ aa.txt 599
@@ aa.txt 600
@@ aa.txt 601
xxxx> @ bb.txt
SYSDATE
-------------------
2018-01-29 16:29:58
SYSDATE
-------------------
2018-01-29 16:39:56
SYSDATE
-------------------
2018-01-29 16:39:56
SYSDATE
-------------------
2018-01-29 16:49:56
SYSDATE
-------------------
2018-01-29 16:49:56
select sysdate from dual
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 13003
Session ID: 706 Serial number: 46389
--//可以看出如果网络空闲600秒,基本断开.
--//根据上面的测试设置SQLNET.EXPIRE_TIME = 4(这个单位是分钟,设置5应该问题不大),或者设置net.ipv4.tcp_keepalive_time = 590.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-2150614/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/267265/viewspace-2150614/