针对Mysql所在linux服务器的系统优化参数

系统参数优化

来源:https://blog.csdn.net/qq_40999403/article/details/80666102


内核相关参数(/etc/sysctl.conf)

对于一个mysql的服务器,我们需要对系统做出一些优化,例如tcp连接数等,来保证mysql性能能达到最优。

主要有以下几个参数。直接在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除非没有足够内存时才使用交换分区

增加资源限制(/etc/security/limit.conf)
打开文件数的限制,针对数据库句柄

* soft nofile 65536
* hard nofile 65535
posted @ 2021-04-07 16:27  MR__Wang  阅读(219)  评论(0编辑  收藏  举报