Centos-服务器初始化内核参数

前言

公司服务器都是用Centos,一般都要针对业务,进行内核参数做些优化。

Centos-服务器初始化内核参数


为了解决问题

修改配置文件/etc/sysctl.conf,内核参数优化,也是为了保障业务服务稳定、安全,使用这套内核参数可提供服务器性能,并能避免iptables_nf_conntrack table full、kernel TCP time wait bucket table overflow等问题。

Centos-服务器初始化内核参数


配置示例

服务器系统是centos7 内存64G,内核参数如下:

net.ipv6.conf.all.disable_ipv6 = 1

net.ipv6.conf.default.disable_ipv6 = 1

net.ipv4.tcp_syn_retries = 1

net.ipv4.tcp_synack_retries = 1

net.ipv4.tcp_keepalive_time = 600

net.ipv4.tcp_keepalive_probes = 3

net.ipv4.tcp_keepalive_intvl =15

net.ipv4.tcp_retries1 = 3

net.ipv4.tcp_retries2 = 5

net.ipv4.tcp_fin_timeout = 10

net.ipv4.tcp_tw_recycle = 1

net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_syncookies = 1

net.ipv4.tcp_window_scaling = 1

net.ipv4.tcp_max_tw_buckets = 60000

net.ipv4.tcp_max_orphans = 32768

net.ipv4.tcp_max_syn_backlog = 16384

net.ipv4.tcp_mem = 94500000 915000000 927000000

net.ipv4.tcp_wmem = 4096 16384 13107200

net.ipv4.tcp_rmem = 4096 87380 17476000

net.ipv4.ip_local_port_range = 1024 65000

net.ipv4.route.gc_timeout = 100

net.core.somaxconn = 32768

net.core.netdev_max_backlog = 32768

net.nf_conntrack_max = 6553500

net.netfilter.nf_conntrack_max = 6553500

net.netfilter.nf_conntrack_tcp_timeout_established = 180

vm.overcommit_memory = 1

vm.swappiness = 1

fs.file-max = 1024000


总结

这些参数是根据平时服务器出现问题时,调整测试的,可以应用于大部分服务器的参数。遇到不同的业务还是根据具体情况进行调整。

相关推荐