0, 调优之ulimit命令
1 2 3 4 5 6 7 8
| ulimit -n # 列出最大打开文件数 ulimit -a # 列出所有资源设置信息 ulimit -HSn 65535 # 软设置最大打开文件数,重启后失效 *常见案例日志,java.net.SocketException:Too many open files* **相关配置文件** /etc/security/limits.conf * soft nofile 65535 * hard nofile 65535
|
1, 系统内核参数调优
常见案例日志,kernel:ip_conntrack:table full,dropping packet
在/etc/sysctl.conf加入,最后执行sysctl -p使配置生效
1
| net.nf_conntrack_max = 1000000 # 防止防火墙连接追踪满
|
2, 调优之swappiness参数
表示使用swap的概率,此值越大表示使用swap的概率越大
查看目前配置
1 2
| cat /proc/sys/vm/swappiness vm.swappiness=10 # 表示当内存使用率超过(100-10)90%时,才开始使用swap.
|
4,线上web服务器配置参考,需要根据服务器的配置进行修改
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
| 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_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_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
|