stupid_lee 发表于 2015-07-29 18:07

max_connections参数的疑问

为了做测试,my.cnf将参数设置为5root@localhost] ((none)) 17:57> show variables like '%max_connections%';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 5   |
+-----------------+-------+
1 row in set (0.00 sec)然后我为了达到最大连接数,开了5个终端均执行如下命令# mysql
Welcome to the MySQL monitor.Commands end with ; or \g.
....................

((none)) 18:01> 第6个终端再次连接# mysql
ERROR 1040 (HY000): Too many connections如愿以偿的报错了


但是我登录该mysql所在主机# netstat -anput|grep 3306
tcp      0      0 192.168.1.12:3306         0.0.0.0:*                   LISTEN      6533/mysqld         
tcp      0      0 192.168.1.12:49595          192.168.1.12:3306         ESTABLISHED 6534/mysqld         
tcp      0      0 192.168.1.12:3306         192.168.1.12:49595          ESTABLISHED 6533/mysqld   明明有5个mysql客户端发起的连接,但这里只显示了一个

在已经连接上的mysql上执行 (ProjectM) 17:51> show processlist;
+----+--------+--------------------+----------+-------------+------+-----------------------------------------------------------------------+------------------+
| Id | User   | Host               | db       | Command   | Time | State                                                               | Info             |
+----+--------+--------------------+----------+-------------+------+-----------------------------------------------------------------------+------------------+
|1 | backup | 192.168.1.12:49595 | NULL   | Binlog Dump |894 | Master has sent all binlog to slave; waiting for binlog to be updated | NULL             |
|2 | root   | localhost          | NULL   | Sleep       |875 |                                                                     | NULL             |
|3 | root   | localhost          | ProjectM | Query       |    0 | init                                                                  | show processlist |
|4 | root   | localhost          | ProjectM | Sleep       |752 |                                                                     | NULL             |
|5 | root   | localhost          | ProjectM | Sleep       |731 |                                                                     | NULL             |
|7 | root   | localhost          | NULL   | Sleep       |202 |                                                                     | NULL             |
+----+--------+--------------------+----------+-------------+------+-----------------------------------------------------------------------+------------------+发现也看不到其他几个连接,

问:当生产系统mysql 报错 too many connections 而无法连接的时候,netstat -anput只能发现从非本机发起的连接,若本机多次发起连接则无法检索出来(netstat 将之视为一个连接,但mysql却视为多个),有什么办法能直接看到 造成too many connections的所有连接吗?包括由本机发起的多个连接

lyhabc 发表于 2015-07-30 00:14

再开几个连接

stupid_lee 发表于 2015-07-30 09:24

回复 2# lyhabc
1、已经too many connections 了,如何再开连接
2、就算释放掉一两个连接,然后连接上了,有什么用 ?

   

swenzhao 发表于 2015-08-01 11:40

本帖最后由 swenzhao 于 2015-08-01 11:41 编辑

本机访问使用name pipe,使用netstat 看不到。

除非你带-h参数访问mysql。

action08 发表于 2015-08-03 00:19

本机都是local socket连接的吧

看client的配置文件

renxiao2003 发表于 2015-08-13 10:22

链接数是内部保存的吧。比如你用JDBC连接呢。
页: [1]
查看完整版本: max_connections参数的疑问