mysql连接太多_mysql连接过多的处理

重新升级了cacti 8.07d,运行一天后,发现生成的图形断断续续。查找原因发现是mysql产生了很多sleep连接不释放,以致影响cacti的查询。

mysql> show processlist;

+—-+———–+———–+——-+———+——+——-+——————+

| Id | User      | Host      | db    | Command | Time | State | Info             |

+—-+———–+———–+——-+———+——+——-+——————+

|  1 | root      | localhost | NULL  | Query   |    0 | NULL  | show processlist |

|  3 | cactiuser | localhost | cacti | Sleep   |  409 |       | NULL             |

|  4 | cactiuser | localhost | cacti | Sleep   |  403 |       | NULL             |

|  5 | cactiuser | localhost | cacti | Sleep   |  406 |       | NULL             |

| 20 | cactiuser | localhost | cacti | Sleep   |  401 |       | NULL             |

| 22 | cactiuser | localhost | cacti | Sleep   |  199 |       | NULL             |

| 23 | cactiuser | localhost | cacti | Sleep   |  179 |       | NULL             |

| 24 | cactiuser | localhost | cacti | Sleep   |  158 |       | NULL             |

| 25 | cactiuser | localhost | cacti | Sleep   |  134 |       | NULL             |

| 26 | cactiuser | localhost | cacti | Sleep   |  114 |       | NULL             |

| 41 | cactiuser | localhost | cacti | Sleep   |   90 |       | NULL             |

| 42 | cactiuser | localhost | cacti | Sleep   |   69 |       | NULL             |

| 43 | cactiuser | localhost | cacti | Sleep   |   48 |       | NULL             |

| 44 | cactiuser | localhost | cacti | Sleep   |   28 |       | NULL             |

| 45 | cactiuser | localhost | cacti | Sleep   |    4 |       | NULL             |

+—-+———–+———–+——-+———+——+——-+——————+

15 rows in set (0.00 sec)

mysql> show variables like ‘max_connections’;

+—————–+——-+

| Variable_name   | Value |

+—————–+——-+

| max_connections | 100   |

+—————–+——-+

1 row in set (0.00 sec)

mysql> show status like ‘max_used_connections’;

+———————-+——-+

| Variable_name        | Value |

+———————-+——-+

| Max_used_connections | 24    |

+———————-+——-+

1 row in set (0.00 sec)

mysql> show status like ‘thread%’;

+——————-+——-+

| Variable_name     | Value |

+——————-+——-+

| Threads_cached    | 0     |

| Threads_connected | 19    |

| Threads_created   | 29    |

| Threads_running   | 1     |

+——————-+——-+

4 rows in set (0.00 sec)

mysql> show variables like ‘wait_timeout’;

+—————+——-+

| Variable_name | Value |

+—————+——-+

| wait_timeout  | 28800 |

+—————+——-+

1 row in set (0.00 sec)

修改my.cnf

wait_timeout = 30

interactive_timeout = 30

重启数据库

mysql> show variables like ‘wait_timeout’;

+—————+——-+

| Variable_name | Value |

+—————+——-+

| wait_timeout  | 30 |

+—————+——-+

1 row in set (0.00 sec)

觉得文章有用?立即:

和朋友一起 共学习 共进步!

猜您喜欢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值