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 .


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

查看所有标签

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

Haskell

Haskell

Simon Thompson / Addison-Wesley / 1999-3-16 / GBP 40.99

The second edition of Haskell: The Craft of Functional Programming is essential reading for beginners to functional programming and newcomers to the Haskell programming language. The emphasis is on th......一起来看看 《Haskell》 这本书的介绍吧!

SHA 加密
SHA 加密

SHA 加密工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具