Sysctl配置调优参考
详情请参考 Sysctl中文参考指南
线上Web服务器配置参考(每天3亿PV量)
注明:如果你要应用该配置文件,请慎重!该配置文件未经核实有效性,仅供参考!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| net.ipv4.conf.lo.arp_ignore = 1 net.ipv4.conf.lo.arp_announce = 2 net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2 net.ipv4.tcp_tw_reues = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_max_syn_backlog = 20000 net.core.netdev_max_backlog = 32768 net.core.somaxconn = 32768
net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216
net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syn_retries = 2 net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reues = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_max_orphans=3276800
net.ipv4.tcp_fin_timeout = 10 net.ipv4.tcp_keepalive_time = 120 net.ipv4.ip_local_port_range = 1024 65535 net.ipv4.tcp_max_tw_buckets = 80000 net.ipv4.tcp_keepalive_time = 120 net.ipv4.tcp_keepalive_intvl = 15 net.ipv4.tcp_keepalive_probes = 5
net.ipv4.conf.lo.arp_ignore = 1 net.ipv4.conf.lo.arp_announce = 2 net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2
|
配置文件讲解
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| net.ipv4.conf.lo.arp_ignore = 1 net.ipv4.conf.lo.arp_announce = 2 net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2 net.ipv4.tcp_tw_reues = 1 net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_max_syn_backlog = 20000
net.core.netdev_max_backlog = 32768 #指定在接口接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包的最大数。 net.core.somaxconn = 32768 #限制套接字侦听积压,已知在使用着的somaxconn。默认值为128。如果调整套接字请参阅tcp_max_syn_backlog。
net.core.wmem_default = 8388608 #默认的发送窗口大小 net.core.rmem_default = 8388608 #接收窗口的默认大小 net.core.rmem_max = 16777216 #接收窗口的最大大小 net.core.wmem_max = 16777216 #发送窗口的最大大小
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reues = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000 #此选项里有三个变量:low,pressure,high。
net.ipv4.tcp_max_orphans = 3276800 #系统中最多有多少个TCP套接字不被关联到任何一个用户文件句柄上。如果超过这个数字,孤儿链接将即将被复位并打印出警告信息。这个限制仅仅是为了防止简单的DOS攻击。
net.ipv4.tcp_fin_timeout = 10 #当套接字由本端要求关闭,它决定保持在FIN-WAIT-2状态的时间。默认值为60秒。2.2内核的通常值是180秒。这个数值如果设置太大会出现内存溢出的风险。 net.ipv4.tcp_keepalive_time = 120 #当启用keepalive的时候,TCP发送keepalive消息的频度,默认为2小时。 net.ipv4.ip_local_port_range = 1024 65535 #用于向外连接的宽口范围。默认情况为1024到61000
net.ipv4.tcp_max_tw_buckets = 80000 #系统同时保持timewait套接字的最大数。默认值为180000。 net.ipv4.tcp_keepalive_time = 120 #当启用keepalive的时候,TCP发送keepalive消息的频度,默认为2小时。 net.ipv4.tcp_keepalive_intvl = 15 #当检测没有确认时,重新发送检测的频度,默认是75秒。 net.ipv4.tcp_keepalive_probes = 5
net.ipv4.conf.lo.arp_ignore = 1 net.ipv4.conf.lo.arp_announce = 2 net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2
|
sysctl常用命令使用
加载系统参数 sysctl -p
显示所有系统参数 sysctl -a
临时改变某个指定参数的值 sysctl -w
例如:sysctl -w net.ipv4.ip_forward=1