gpt4 book ai didi

MySQL 需要很长时间(数小时)来确定丢失的连接

转载 作者:行者123 更新时间:2023-11-29 00:58:03 24 4
gpt4 key购买 nike

我们有一项服务可以在同一个单独的服务器上访问几个数据库。服务宕机了,但是 mysql 并没有中止所有的连接,而是让一个连接打开了很长时间。下面是一个mysql日志。我们可以根据连接 ID 看到,最后一行报告的连接应该在 00:01 与其他连接一起中止,但它停留了 2 个多小时。

110216  0:00:01 [Warning] Aborted connection 11864307 to db: 'foodb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11865442 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11864559 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11863856 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11865445 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11864581 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11865447 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11864566 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11865451 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11865446 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11865444 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11864565 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11865490 to db: 'foodb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11864251 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11864299 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11864303 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11865486 to db: 'foodb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11864304 to db: 'foodb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11864560 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11864268 to db: 'foodb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11865055 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11865443 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:01 [Warning] Aborted connection 11865450 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:02 [Warning] Aborted connection 11865448 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 0:00:02 [Warning] Aborted connection 11865485 to db: 'foodb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)
110216 2:11:17 [Warning] Aborted connection 11865449 to db: 'bardb' user: 'db_user' host: '10.234.1.15' (Got an error reading communication packets)

现在,假设这是 mysql 的问题,给定以下超时设置,是否有任何可能导致此问题的原因?

mysql> show variables like '%time%';
+----------------------------+-------------------+
| Variable_name | Value |
+----------------------------+-------------------+
| connect_timeout | 10 |
| datetime_format | %Y-%m-%d %H:%i:%s |
| delayed_insert_timeout | 300 |
| flush_time | 0 |
| innodb_lock_wait_timeout | 600 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 28800 |
| lc_time_names | en_US |
| long_query_time | 5 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| slave_net_timeout | 3600 |
| slow_launch_time | 2 |
| system_time_zone | GMT |
| table_lock_wait_timeout | 50 |
| time_format | %H:%i:%s |
| time_zone | SYSTEM |
| timed_mutexes | OFF |
| wait_timeout | 28800 |
+----------------------------+-------------------+

mysql> show variables like '%packet%';
+--------------------+----------+
| Variable_name | Value |
+--------------------+----------+
| max_allowed_packet | 16777216 |
+--------------------+----------+

最佳答案

您的 max_allowed_size 必须默认为 1M,并且您是否使用大量数据、blob 或其他内容进行了一些查询。将该值增加到 8M(1GB 是最大限制)。

将 wait_timeout 减少到 50 左右。

wait_timeout 是 “服务器在关闭非交互式连接之前等待事件的秒数。此超时仅适用于 TCP/IP 和 Unix 套接字文件连接,不适用于使用命名管道建立的连接,或共享内存。” Details

关于MySQL 需要很长时间(数小时)来确定丢失的连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5068548/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com