首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么MySQL允许比max_connections限制更多的连接?

问为什么MySQL允许比max_connections限制更多的连接?
EN

Server Fault用户
提问于 2020-12-15 08:28:49
回答 2查看 666关注 0票数 1

这是我的连接数据。

代码语言:javascript
复制
mysql> show status like 'Conn%';
+-----------------------------------+-------+
| Variable_name                     | Value |
+-----------------------------------+-------+
| 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                       | 274   |
+-----------------------------------+-------+
代码语言:javascript
复制
mysql> SHOW VARIABLES LIKE 'max_%';
+----------------------------+----------------------+
| Variable_name              | Value                |
+----------------------------+----------------------+
| max_allowed_packet         | 16777216             |
| max_binlog_cache_size      | 18446744073709547520 |
| max_binlog_size            | 104857600            |
| max_binlog_stmt_cache_size | 18446744073709547520 |
| max_connect_errors         | 100                  |
| max_connections            | 151                  |
| max_delayed_threads        | 20                   |
| max_digest_length          | 1024                 |
| max_error_count            | 64                   |
| max_execution_time         | 0                    |
| max_heap_table_size        | 16777216             |
| max_insert_delayed_threads | 20                   |
| max_join_size              | 18446744073709551615 |
| max_length_for_sort_data   | 1024                 |
| max_points_in_geometry     | 65536                |
| max_prepared_stmt_count    | 16382                |
| max_relay_log_size         | 0                    |
| max_seeks_for_key          | 18446744073709551615 |
| max_sort_length            | 1024                 |
| max_sp_recursion_depth     | 0                    |
| max_tmp_tables             | 32                   |
| max_user_connections       | 0                    |
| max_write_lock_count       | 18446744073709551615 |
+----------------------------+----------------------+

我想知道为什么允许比max_connections限制更多的连接?mysql不应该拒绝更多的连接,还是缓慢地修剪旧的连接?从日志中可以看出,后者是真的吗?

代码语言:javascript
复制
tail -f /var/log/mysql/error.log
2020-12-15T07:21:59.253969Z 60 [Note] Aborted connection 60 to db: 'my_db' user: 'my_user' host: 'my_ip' (Got an error reading communication packets)
2020-12-15T07:21:59.253979Z 57 [Note] Aborted connection 57 to db: 'my_db' user: 'my_user' host: 'my_ip' (Got an error reading communication packets)
2020-12-15T07:21:59.253994Z 56 [Note] Aborted connection 56 to db: 'my_db' user: 'my_user' host: 'my_ip' (Got an error reading communication packets)
2020-12-15T07:21:59.254119Z 58 [Note] Aborted connection 58 to db: 'my_db' user: 'my_user' host: 'my_ip' (Got an error reading communication packets)
2020-12-15T07:21:59.254136Z 54 [Note] Aborted connection 54 to db: 'my_db' user: 'my_user' host: 'my_ip' (Got an error reading communication packets)
2020-12-15T07:21:59.254143Z 59 [Note] Aborted connection 59 to db: 'my_db' user: 'my_user' host: 'my_ip' (Got an error reading communication packets)
2020-12-15T07:21:59.254154Z 61 [Note] Aborted connection 61 to db: 'my_db' user: 'my_user' host: 'my_ip' (Got an error reading communication packets)
2020-12-15T07:21:59.254565Z 55 [Note] Aborted connection 55 to db: 'my_db' user: 'my_user' host: 'my_ip' (Got an error reading communication packets)
2020-12-15T07:21:59.254581Z 53 [Note] Aborted connection 53 to db: 'my_db' user: 'my_user' host: 'my_ip' (Got an error reading communication packets)
2020-12-15T07:21:59.254593Z 62 [Note] Aborted connection 62 to db: 'my_db' user: 'my_user' host: 'my_ip' (Got an error reading communication packets)

这是否意味着,如果不再需要数据,那么关闭旧连接并不重要,因为mysql会慢慢地修剪这些连接吗?

EN

回答 2

Server Fault用户

发布于 2020-12-15 08:54:24

我认为,查看同时处理了多少连接的参数是Max_used_connections。

自上次重新启动以来,Connections字段应该充当连接的计数器。

连接到MySQL服务器的连接尝试次数(成功与否)。Max_used_connections :自服务器启动以来同时使用的最大连接数。

您可以进一步参考这个SE回答和文献资料。

票数 2
EN

Server Fault用户

发布于 2020-12-15 08:52:49

这不是活动连接的数量。Connections是连接尝试成功与否的次数。您需要查看Threads_connected号码。您还可以使用netstat和mysql端口上的过滤器检查连接。

这是类似的帖子来自stackoverlow。

票数 1
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1046211

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档