Galera 集群有太多连接问题

Galera clusters with too many connections issue

当我运行命令查看我们的数据库变量时:

show status like "%onn%"

我发现 2 人连接的连接太多了:

MariaDB [(none)]> show status like "%onn%";
+-----------------------------------------------+-------+
| Variable_name                                 | Value |
+-----------------------------------------------+-------+
| Aborted_connects                              | 0     |
| Connection_errors_accept                      | 0     |
| Connection_errors_internal                    | 0     |
| Connection_errors_max_connections             | 0     |
| Connection_errors_peer_address                | 0     |
| Connection_errors_select                      | 0     |
| Connection_errors_tcpwrap                     | 0     |
| Connections                                   | 56711 |
| Max_used_connections                          | 11    |
| Performance_schema_session_connect_attrs_lost | 0     |
| Slave_connections                             | 0     |
| Slaves_connected                              | 0     |
| Ssl_client_connects                           | 0     |
| Ssl_connect_renegotiates                      | 0     |
| Ssl_finished_connects                         | 0     |
| Threads_connected                             | 5     |
| wsrep_connected                               | ON    |
+-----------------------------------------------+-------+
17 rows in set (0.00 sec)

连接数没有下降。一直在增加。

CPU Utilization (Percent): 0.82%
KiB Mem :  4045012 total,  1625720 free,   718928 used

如何诊断此问题以找到根本原因?

它崩溃了,我怀疑它可能会再次崩溃。

更新:根据此 MySQL show status - active or total connections?,Threads_connected 是我应该寻找开放连接的值。呸!太棒了!

然而,我的processlist可能非常可疑。注意到 Time 列了吗?他们应该那么高吗?

MariaDB [(none)]> SHOW FULL processlist;
+------+---------------+-----------------+------------+---------+-------+-------------------------+-----------------------+----------+
| Id   | User          | Host            | db         | Command | Time  | State                   | Info                  | Progress |
+------+---------------+-----------------+------------+---------+-------+-------------------------+-----------------------+----------+
|    1 | system user   |                 | NULL       | Sleep   | 23321 | wsrep aborter idle      | NULL                  |    0.000 |
|    2 | system user   |                 | NULL       | Sleep   |  3955 | committed 3040010       | NULL                  |    0.000 |
|    5 | system user   |                 | NULL       | Daemon  |  NULL |                         | NULL                  |    0.000 |
|    6 | system user   |                 | NULL       | Daemon  |  NULL |                         | NULL                  |    0.000 |
|    3 | system user   |                 | NULL       | Daemon  |  NULL |                         | NULL                  |    0.000 |
|    4 | system user   |                 | NULL       | Daemon  |  NULL |                         | NULL                  |    0.000 |
|    7 | system user   |                 | NULL       | Daemon  |  NULL | InnoDB shutdown handler | NULL                  |    0.000 |
|    9 | system user   |                 | NULL       | Sleep   |  3957 | committed 3040009       | NULL                  |    0.000 |
|   10 | system user   |                 | NULL       | Sleep   |  3950 | committed 3040033       | NULL                  |    0.000 |
|   11 | system user   |                 | NULL       | Sleep   |  3954 | committed 3040022       | NULL                  |    0.000 |
|   12 | system user   |                 | NULL       | Sleep   |  3954 | committed 3040020       | NULL                  |    0.000 |
|   16 | system user   |                 | NULL       | Sleep   |  3953 | committed 3040030       | NULL                  |    0.000 |
|   17 | system user   |                 | NULL       | Sleep   |  3949 | committed 3040034       | NULL                  |    0.000 |
|   15 | system user   |                 | NULL       | Sleep   |  3953 | committed 3040031       | NULL                  |    0.000 |
| 9670 | xxx           | localhost:51574 | tabl_name  | Sleep   |     4 |                         | NULL                  |    0.000 |
| 9671 | xxx           | localhost:51576 | NULL       | Sleep   |    53 |                         | NULL                  |    0.000 |
| 9939 | xxx           | localhost       | NULL       | Sleep   |   123 |                         | NULL                  |    0.000 |
| 9942 | xxx           | localhost       | NULL       | Query   |     0 | init                    | SHOW FULL processlist |    0.000 |
+------+---------------+-----------------+------------+---------+-------+-------------------------+-----------------------+----------+
18 rows in set (0.00 sec)

不慌不忙。 Connections 是一个计数器。这些比较有趣Connections / UptimeThreads_running。请注意 Max_used_connections 只有 11。没关系。

请提供 * 内存大小 * SHOW VARIABLES; * SHOW GLOBAL STATUS; -- 在 运行 至少一天后

你有某种形式的"connection pooling"吗?代理服务器?最大尺度?代理?也许您看到的是 "pooled" 连接,而不是真实连接。