CentOS系统参数优化
这里简单介绍一些系统参数的优化,
1. 内核相关参数(/etc/sysctl.conf)
# 每个连接的最大长度
1 net.core.somaxconn = 65535
# 当网络接受速率大于内核处理速率时,允许发送到队列中的包数目
2 net.core.netdev_max_backlog = 65535
# 保持未连接的包最大数量
3 net.ipv4.tcp_max_syn_backlog = 65535
# 控制tcp链接等待时间 加快tcp链接回收
4 net.ipv4.tcp_fin_timeout = 10
5 net.ipv4.tcp_tw_reuse = 1
6 net.ipv4.tcp_tw_recycle = 1
# 决定tcp接受缓冲区的大小,设置大一些比较好
7 net.core.wmem_default = 87380
8 net.core.wmem_max = 16777216
9 net.core.rmem_default = 87380
10 net.core.rmem_max = 16777216
# 对于tcp失效链接占用系统资源的优化,加快资源回收效率
11 net.ipv4.tcp_keepalive_time = 120 # 链接有效时间
12 net.ipv4.tcp_keepalive_intvl = 30 # tcp未获得相应时重发间隔
13 net.ipv4.tcp_keepalive_probes = 3 # 重发数量
# 内核相关参数
# 共享内存下容纳innodb缓冲池的大小
14 kernel.shmmax = 4294967285 # 4G 大小一般为物理内存-1byte
15 vm.swappiness = 0 # linux除非没有足够内存时才使用交换分区
2 增加资源限制(/etc/security/limit.conf)
提高文件数限制
-
* soft nofile 65536
-
* hard nofile 65536
3 io优化
使用noattime 进行磁盘挂载
使用ssd 以及raid 10,以是高性能 。
格式为xfs 或者ext4