[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
- [OS/Linux] Linux核心引數:net.core.somaxconn(高併發場景核心引數)Linux
- oracle rac 核心引數詳解Oracle
- linux常用核心引數說明Linux
- histb 引導核心 boot_cmd 引數含義boot
- Yarn生產環境核心引數Yarn
- linux核心引數優化重要項Linux優化
- swoole優化核心引數調整優化
- [20210826]核心引數kernel.sem.txt
- Oracle中的sysctl.conf核心引數Oracle
- 在Linux中,linux核心引數如何修改?Linux
- 認識Tomcat核心元件及其啟動引數Tomcat元件
- 大資料叢集核心引數調優大資料
- 核心引數kernel.shmall和kernel.shmmaxHMM
- CentOS升級核心與容器執行時核心引數的關係CentOS
- Guava Cache:核心引數深度剖析和原始碼分析Guava原始碼
- Linux核心引數overcommit_memory和OOM killer介紹LinuxMITOOM
- Linux 核心引數 arp_ignore & arp_announce 詳解Linux
- 如何在 Fedora 30 中設定核心命令列引數命令列
- Linux核心版本以及部分引數與效能之二Linux
- 【轉載】Linux核心除錯之使用模組引數Linux除錯
- 大資料學習—Kafka的核心調優引數大資料Kafka
- 【kernel】從 /proc/sys/net/ipv4/ip_forward 引數看如何玩轉 procfs 核心引數Forward
- DBA不可不知的作業系統核心引數作業系統
- Oracle 效能最佳化之核心的shmall 和shmmax 引數OracleHMM
- 用好語言模型:temperature、top-p等核心引數解析模型
- solaris10中安裝oracle核心引數的調整Oracle
- Nginx配置和Linux核心引數的學習與驗證NginxLinux
- 通過原始碼理解 Java 執行緒池的核心引數原始碼Java執行緒
- [轉帖]Redis相關的核心引數解釋與設定Redis
- 什麼是請求引數、表單引數、url引數、header引數、Cookie引數?一文講懂HeaderCookie
- DIY 實現 ThinkPHP 核心框架 (十三)利用反射實現引數繫結PHP框架反射
- python疑問5:位置引數,預設引數,可變引數,關鍵字引數,命名關鍵字引數區別Python
- 12.MyBatis學習--對映檔案_引數處理_單個引數&多個引數&命名引數MyBatis
- c++11-17 模板核心知識(五)—— 理解模板引數推導規則C++
- c++11-17 模板核心知識(十二)—— 模板的模板引數 Template Template ParametersC++
- Java對比有引數和無引數Java
- 引數配置
- python引數Python