mysql - 优化(max_connection, thread_cache_size 等的设置)

栏目: 数据库 · 发布时间: 7年前

内容简介:参考:今天我们的服务器的自我检测程序停掉了.原因很有意思,mysql 的最大连接数超过了上线, 报错.

参考: https://serverfault.com/questions/408845/what-value-of-thread-cache-size-should-i-use

今天我们的服务器的自我检测程序停掉了.

原因很有意思,mysql 的最大连接数超过了上线, 报错.

结局办法: (修改配置文件之后记得重启)

修改 mysql 的配置 (/etc/mysql/my.cnf ) 设置

[mysqld]

max_connections  = 2000

或者更高.

另外, thread_cache_size 也需要设置, 设置办法:

1. 查看3个参数;

mysql> show global status like 'Connections'
    -> ;
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections   | 368   |
+---------------+-------+

mysql> show global status like 'Threads_created';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| Threads_created | 181   |
+-----------------+-------+

mysql> show global status like 'Max_used_connections';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| Max_used_connections | 152   |
+----------------------+-------+

然后,     Threads_created / Connections  如果 > 0.01 那么 就需要增加 thread_cache_size

thread_cache_size 必须要高于   Max_used_connections .


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Designing Data-Intensive Applications

Designing Data-Intensive Applications

Martin Kleppmann / O'Reilly Media / 2017-4-2 / USD 44.99

Data is at the center of many challenges in system design today. Difficult issues need to be figured out, such as scalability, consistency, reliability, efficiency, and maintainability. In addition, w......一起来看看 《Designing Data-Intensive Applications》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

SHA 加密
SHA 加密

SHA 加密工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具