重新升级了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)