ITPub博客

首页 > 数据库 > Oracle > [20200224]观察使用TCP keep-alive feature特性.txt

[20200224]观察使用TCP keep-alive feature特性.txt

原创 Oracle 作者:lfree 时间:2020-02-25 09:31:36 0 删除 编辑

[20200224]观察使用TCP keep-alive feature特性.txt

--//前几天测试,提到观察使用TCP keep-alive feature特性,可以执行netsta -npo | grep <进程号>确定,这是一种简单快捷的方式。
--//实际上可以ss -nop观察可以获得一样的效果.

1.环境:
--//服务端设置:
SCOTT@book> @ 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

# echo /proc/sys/net/ipv4/tcp_keepalive* | xargs   -n 1  strings -1 -f
/proc/sys/net/ipv4/tcp_keepalive_intvl: 75
/proc/sys/net/ipv4/tcp_keepalive_probes: 9
/proc/sys/net/ipv4/tcp_keepalive_time: 7200

$ grep SQLNET.EXPIRE_TIME $ORACLE_HOME/network/admin/sqlnet.ora
#SQLNET.EXPIRE_TIME = 1

2.测试:
# netstat -ntop 2>/dev/null
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name    Timer
tcp        0      0 192.168.100.78:59597        192.168.100.78:1521         ESTABLISHED 52283/ora_pmon_book off (0.00/0/0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tcp        0      0 192.168.100.78:22           192.168.98.6:58436          ESTABLISHED 52769/sshd          keepalive (3359.89/0/0)
tcp        0      0 192.168.100.78:22           192.168.98.6:51182          ESTABLISHED 51346/sshd          keepalive (2884.83/0/0)
tcp        0      0 192.168.100.78:33066        192.168.xx.xxx:1521         ESTABLISHED 53413/sqlplus       off (0.00/0/0)
tcp        0      0 192.168.100.78:1521         192.168.100.78:59597        ESTABLISHED 52834/tnslsnr       keepalive (3507.32/0/0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--//sqlplus 进程没有使用 ENABLE=BROKEN连接,可以发现它的keepalive timer状态是off.
--//有点奇怪的是ora_pmon_book进程也是off,我已经重启监听的情况下再启动数据库的情况下也是一样.
--//自己还有一个疑问,如果不起监听进程,ora_pmon_book看到是什么情况呢?
--//注意看下划线内容,ora_pmon_book进程与tnslsnr进程的网络连接是配对的.留在以后测试.

--//实际上还可以使用ss -ntop命令。
# ss -ntop| expand
State      Recv-Q Send-Q        Local Address:Port          Peer Address:Port
ESTAB      0      0            192.168.100.78:59597       192.168.100.78:1521   users:(("oracle",52283,10))
ESTAB      0      0            192.168.100.78:22            192.168.98.6:58436  timer:(keepalive,54min,0) users:(("sshd",52769,3))
ESTAB      0      0            192.168.100.78:22            192.168.98.6:51182  timer:(keepalive,47min,0) users:(("sshd",51346,3))
ESTAB      0      0            192.168.100.78:33066       192.168.xx.xxx:1521   users:(("sqlplus",53413,7))
ESTAB      0      0            192.168.100.78:1521        192.168.100.78:59597  timer:(keepalive,57min,0) users:(("tnslsnr",52834,12))
--//ss -ntop显示如果时间很大,显示的单位是min.后面users还记录的很多信息,第1个参数是进程名,第2个参数是进程号,第3个参数是
--//socket对应的文件句柄.

--//修改如下:
# 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: 33

SCOTT@78> @ spid
SID SERIAL# PROCESS   SERVER    SPID  PID  P_SERIAL# C50
--- ------- --------- --------- ----- --- ---------- -------------------------------------------
  1      99 4328:3512 DEDICATED 53495  24         33 alter system kill session '1,99' immediate;

# seq 40 | xargs -IQ bash -c "ss -ntop | expand | grep 53495;sleep 1"
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,614ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,9.569ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,8.508ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,7.449ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,6.388ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,5.329ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,4.268ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,3.209ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,2.149ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,1.090ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,028ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,21sec,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,20sec,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,19sec,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,18sec,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,17sec,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,16sec,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,15sec,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,14sec,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,13sec,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,12sec,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,11sec,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,10sec,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,9.249ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,8.188ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,7.129ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,6.068ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,5.009ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,3.948ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,2.887ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,1.828ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,767ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,9.724ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,8.664ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,7.604ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,6.543ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,5.484ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,4.425ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,3.362ms,0) users:(("oracle",53495,13))
ESTAB      0      0  192.168.100.78:1521  192.168.98.6:61642  timer:(keepalive,2.302ms,0) users:(("oracle",53495,13))
--//看到的与netstat看到一样,你可以发现keepalive分成2部分,1部分10秒,1部分23秒?.
--//使用netstat看到的情况如下.
# seq 40 | xargs -IQ bash -c "netstat -nop |  grep 53495;sleep 1"
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (1.72/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (0.69/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (9.68/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (8.66/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (7.63/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (6.61/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (5.58/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (4.56/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (3.53/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (2.51/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (1.48/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (0.46/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (22.44/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (21.42/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (20.39/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (19.37/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (18.34/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (17.32/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (16.29/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (15.27/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (14.24/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (13.22/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (12.20/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (11.17/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (10.15/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (9.12/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (8.10/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (7.07/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (6.05/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (5.03/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (4.00/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (2.98/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (1.95/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (0.93/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (9.92/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (8.89/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (7.87/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (6.84/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (5.82/0/0)
tcp        0      0 192.168.100.78:1521  192.168.98.6:61642  ESTABLISHED 53495/oraclebook    keepalive (4.80/0/0)
--//windows下有什么工具或者命令行观察keealive timer呢?那位知道...

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-2677064/,如需转载,请注明出处,否则将追究法律责任。

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

注册时间:2008-01-03

  • 博文量
    2669
  • 访问量
    6427886