[20180126]核心引數tcp_keepalive.txt
[20180126]核心引數tcp_keepalive.txt
--//linux核心引數tcp_keepalive,用來檢查網路鏈路是否有效.預設:
# 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
引數解析:
/proc/sys/net/ipv4/tcp_keepalive_time 當keepalive起用的時候,TCP傳送keepalive訊息的頻度。預設是2小時。
/proc/sys/net/ipv4/tcp_keepalive_intvl 當探測沒有確認時,keepalive探測包的傳送間隔。預設是75秒。
/proc/sys/net/ipv4/tcp_keepalive_probes 如果對方不予應答,keepalive探測包的傳送次數。預設值是9。
--//預設定義的TCP傳送keepalive訊息的頻度,預設是2小時。
--//我以前做過測試,連結:http://blog.itpub.net/267265/viewspace-2138391/
--//當時測試對應oracle的連線,如果設定sqlnet.expire_time引數,核心引數無效.
--//而且我在許多測試提到如果使用sqlnet.expire_time引數,最大間隔是2倍的sqlnet.expire_time,也就是在1個sqlnet.expire_time時間段內,
--//如果有資料包在連線接收傳送,監測包不會傳送.
--//參考連結:http://blog.itpub.net/267265/viewspace-2150499/
--//而使用linux核心引數tcp_keepalive引數與使用sqlnet.expire_time還是有點點不同:
--//註解sqlnet.expire_time引數,設定核心引數如下:
--//修改/etc/sysctl.conf 加入如下:
net.ipv4.tcp_keepalive_time = 180
net.ipv4.tcp_keepalive_intvl = 10
net.ipv4.tcp_keepalive_probes = 4
# sysctl -p
$ 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: 180
--//開啟tcpdump的同時,啟動一個新會話(遠端).
# tcpdump -i eth0 host 192.168.98.6 and not port 22 -nn -vv
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
09:45:32.852127 IP (tos 0x0, ttl 127, id 1649, offset 0, flags [DF], proto: TCP (6), length: 52) 192.168.98.6.57017 > 192.168.100.78.1521: S, cksum 0x362f (correct), 3423871106:3423871106(0) win 8192 <mss 1460,nop,wscale 2,nop,nop,sackOK>
09:45:32.852176 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto: TCP (6), length: 52) 192.168.100.78.1521 > 192.168.98.6.57017: S, cksum 0x47cc (incorrect (-> 0x464b), 1678537401:1678537401(0) ack 3423871107 win 14600 <mss 1460,nop,nop,sackOK,nop,wscale 7>
...
09:45:33.175785 IP (tos 0x0, ttl 64, id 39960, offset 0, flags [DF], proto: TCP (6), length: 57) 192.168.100.78.1521 > 192.168.98.6.57017: P, cksum 0x47d1 (incorrect (-> 0x76cb), 6608:6625(17) ack 7937 win 330
09:45:33.176049 IP (tos 0x0, ttl 127, id 1696, offset 0, flags [DF], proto: TCP (6), length: 52) 192.168.98.6.57017 > 192.168.100.78.1521: ., cksum 0x303e (correct), 7937:7937(0) ack 6625 win 16307 <nop,nop,sack 1 {6608:6625}>
--//不執行任何sql語句.
09:48:33.400755 IP (tos 0x0, ttl 64, id 39961, offset 0, flags [DF], proto: TCP (6), length: 40) 192.168.100.78.1521 > 192.168.98.6.57017: ., cksum 0x47c0 (incorrect (-> 0x85fc), 6624:6624(0) ack 7937 win 330
09:48:33.401006 IP (tos 0x0, ttl 127, id 5703, offset 0, flags [DF], proto: TCP (6), length: 40) 192.168.98.6.57017 > 192.168.100.78.1521: ., cksum 0x4792 (correct), 7937:7937(0) ack 6625 win 16307
09:51:33.624757 IP (tos 0x0, ttl 64, id 39962, offset 0, flags [DF], proto: TCP (6), length: 40) 192.168.100.78.1521 > 192.168.98.6.57017: ., cksum 0x47c0 (incorrect (-> 0x85fc), 6624:6624(0) ack 7937 win 330
09:51:33.625026 IP (tos 0x0, ttl 127, id 7103, offset 0, flags [DF], proto: TCP (6), length: 40) 192.168.98.6.57017 > 192.168.100.78.1521: ., cksum 0x4792 (correct), 7937:7937(0) ack 6625 win 16307
09:54:33.848760 IP (tos 0x0, ttl 64, id 39963, offset 0, flags [DF], proto: TCP (6), length: 40) 192.168.100.78.1521 > 192.168.98.6.57017: ., cksum 0x47c0 (incorrect (-> 0x85fc), 6624:6624(0) ack 7937 win 330
09:54:33.848986 IP (tos 0x0, ttl 127, id 8121, offset 0, flags [DF], proto: TCP (6), length: 40) 192.168.98.6.57017 > 192.168.100.78.1521: ., cksum 0x4792 (correct), 7937:7937(0) ack 6625 win 16307
09:57:34.072758 IP (tos 0x0, ttl 64, id 39964, offset 0, flags [DF], proto: TCP (6), length: 40) 192.168.100.78.1521 > 192.168.98.6.57017: ., cksum 0x47c0 (incorrect (-> 0x85fc), 6624:6624(0) ack 7937 win 330
09:57:34.072989 IP (tos 0x0, ttl 127, id 9256, offset 0, flags [DF], proto: TCP (6), length: 40) 192.168.98.6.57017 > 192.168.100.78.1521: ., cksum 0x4792 (correct), 7937:7937(0) ack 6625 win 16307
--//可以發現間隔3分鐘.
--//在會話執行如下:
SCOTT@78> select sysdate from Dual ;
SYSDATE
-------------------
2018-01-26 09:57:54
09:57:54.443243 IP (tos 0x0, ttl 127, id 9364, offset 0, flags [DF], proto: TCP (6), length: 303) 192.168.98.6.57017 > 192.168.100.78.1521: P 7937:8200(263) ack 6625 win 16307
09:57:54.445202 IP (tos 0x0, ttl 64, id 39965, offset 0, flags [DF], proto: TCP (6), length: 308) 192.168.100.78.1521 > 192.168.98.6.57017: P 6625:6893(268) ack 8200 win 330
09:57:54.463455 IP (tos 0x0, ttl 127, id 9366, offset 0, flags [DF], proto: TCP (6), length: 61) 192.168.98.6.57017 > 192.168.100.78.1521: P, cksum 0x25c1 (correct), 8200:8221(21) ack 6893 win 16240
09:57:54.463592 IP (tos 0x0, ttl 64, id 39966, offset 0, flags [DF], proto: TCP (6), length: 142) 192.168.100.78.1521 > 192.168.98.6.57017: P 6893:6995(102) ack 8221 win 330
09:57:54.666785 IP (tos 0x0, ttl 64, id 39967, offset 0, flags [DF], proto: TCP (6), length: 142) 192.168.100.78.1521 > 192.168.98.6.57017: P 6893:6995(102) ack 8221 win 330
09:57:54.667035 IP (tos 0x0, ttl 127, id 9368, offset 0, flags [DF], proto: TCP (6), length: 52) 192.168.98.6.57017 > 192.168.100.78.1521: ., cksum 0x2b7e (correct), 8221:8221(0) ack 6995 win 16214 <nop,nop,sack 1 {6893:6995}>
--//執行sql語句時的情況.等....
10:00:54.712765 IP (tos 0x0, ttl 64, id 39968, offset 0, flags [DF], proto: TCP (6), length: 40) 192.168.100.78.1521 > 192.168.98.6.57017: ., cksum 0x47c0 (incorrect (-> 0x836e), 6994:6994(0) ack 8221 win 330
10:00:54.713009 IP (tos 0x0, ttl 127, id 10523, offset 0, flags [DF], proto: TCP (6), length: 40) 192.168.98.6.57017 > 192.168.100.78.1521: ., cksum 0x4561 (correct), 8221:8221(0) ack 6995 win 16214
--//可以發現間隔3分鐘.但是從執行sql語句後算起.而不是從09:57:34.072989.
--//如果對比還是可以看出兩者的區別:
--//使用核心引數空閒tcp_keepalive_time發出監測包.
--//而使用sqlnet.expire_time引數,它是從連線開始算起,間隔1個sqlnet.expire_time時間內,如果有資料包傳送,就不傳送監測包.這樣就會出現最大間隔
--//2個sqlnet.expire_time的情況,感覺這東西表達有點困難.大家還是看連結的測試把:http://blog.itpub.net/267265/viewspace-2150499/
--//從某種意義講我感覺使用核心引數更加科學.而且可以更加科學的控制如果鏈路出問題時的探測次數以及時間間隔.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2150541/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 核心引數Oracle
- ORACLE核心引數Oracle
- 核心引數(轉)
- linux 核心引數Linux
- Linux核心引數Linux
- 談談ORACLE核心引數Oracle
- oracle核心引數意義Oracle
- 核心引數意義(轉)
- Linux核心引數以及Oracle引數調整(updated)LinuxOracle
- oracle rac 核心引數詳解Oracle
- Linux核心引數調優Linux
- linux核心啟動引數Linux
- Oracle和SUN Solaris核心引數Oracle
- Linux 核心引數 和 Oracle相關引數調整LinuxOracle
- Linux 核心引數及Oracle相關引數調整LinuxOracle
- (轉)Linux 核心引數及Oracle相關引數調整LinuxOracle
- histb 引導核心 boot_cmd 引數含義boot
- linux常用核心引數說明Linux
- swoole優化核心引數調整優化
- Yarn生產環境核心引數Yarn
- Linux 核心引數優化(for oracle)Linux優化Oracle
- LinuxSysctl調整核心引數Linux
- HP-UX調整核心引數UX
- HP-UX核心引數詳解UX
- Oracle和SUN Solaris核心引數(轉)Oracle
- [OS/Linux] Linux核心引數:net.core.somaxconn(高併發場景核心引數)Linux
- linux核心引數優化重要項Linux優化
- linux和aix核心引數檢查LinuxAI
- 在Solaris10上配置核心引數
- linux核心引數最佳化(七)Linux
- linux核心引數最佳化1Linux
- 系統核心引數 設定 systemv (ipc)
- AIX作業系統核心引數配置AI作業系統
- oracle相關的linux核心引數OracleLinux
- Linux核心引數(如kernel.shmmax)及Oracle相關引數調整LinuxHMMOracle
- linux核心命令列引數速查手冊Linux命令列
- Oracle中的sysctl.conf核心引數Oracle
- linux /proc/sys/vm下核心引數解析Linux