返回顶部
关闭软件导航
位置:首页 > 资讯 > 其他>MySQL中经典的too many connection怎么破

  兰春,58安居客资深DBA,专注于MySQL领域的运维与运营。

  一、什么是too many connection

  1、重要参数

  max_connections : The maximum permitted number of simultaneous client connections

  允许的最大的链接数MySQL文章入库助手 ,如果超过这个数值,则会报:ERROR 1040 (HY000): Too many connections

  max_user_connections: The maximum number of simultaneous connections permitted to any given MySQL user account

  允许的每个用户最大链接数,如果超过这个数值,则会报: ERROR 1203 (42000): User dba already has more than 'max_user_connections' active connectionsmysql文章入库软件。

  一般这样的报错只会出现在业务机器上,并不会在DB server层报错,这样的话DBA就无法真正感知到错误,MySQL也非常贴心的推出了一个status供DBA查看:Connection_errors_max_connections

  Connection_errors_max_connections : The number of connections refused because the server max_connections limit was reached.

  细心的同学就会发现:那如果出现'max_user_connections' 的报错,就无法发现啦mysql文件入库工具 ,这块目前我还没找到对应status。

mysql文件入库工具

  二、什么情况下会发生too many connection

  1、slow query 引起

  真正的slow:该query的确非常慢

  伪装的slow:该query本身并不慢,是受其它因素的影响导致

  2、sleep 空连接引起

  没有任何query,只是sleep,这种情况一般是代码里面没有主动及时释放链接导致。

  三、实战案例

mysql文章入库软件

  1、sleep 空链接引起的TMC(too many connection简称)

如果您觉得 MySQL中经典的too many connection怎么破 这篇文章对您有用,请分享给您的好友,谢谢
文章地址:https://www.tianxianmao.com/article/other/MySQLzjddtoomanyconnectionzmp.html
解放双手无尽可能,有问题添加天线猫微信