使服務器支持100萬長連接的內核參數修改方法

硬件配置如下:
CPU  : 48核心  Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
內存 :總量:188G 使用量:18G
硬盤 :SSD 240G


系統參數優化如下:
1. vi /etc/sysctl.conf

net.ipv4.tcp_syncookies = 1
net.core.somaxconn = 8192  
net.core.rmem_default = 262144  
net.core.wmem_default = 262144  
net.core.rmem_max = 16777216  
net.core.wmem_max = 16777216  
net.ipv4.tcp_rmem = 40960 40960 16777216  
net.ipv4.tcp_wmem = 40960 40960 16777216  
net.ipv4.tcp_mem = 786432 2097152 3145728  
net.ipv4.tcp_max_syn_backlog = 60000  
net.core.netdev_max_backlog = 100000  
net.ipv4.tcp_fin_timeout = 15  
net.ipv4.tcp_tw_reuse = 1  
net.ipv4.tcp_tw_recycle = 1  
net.ipv4.tcp_max_orphans = 1000000
fs.file-max = 1048576
net.ipv4.ip_local_port_range = 1024 65535
net.netfilter.nf_conntrack_max = 1000000

/sbin/sysctl -p

2. 
(需要重啓)
vi /etc/security/limits.conf

* soft nofile 100000
* hard nofile 120000

(不需要重啓)
ulimit -Hn 100000
ulimit -Sn 120000

3. vi /etc/pam.d/login
session required /lib/security/pam_limits.so
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章