Communication Errors and Aborted Connections
很多开发看到如下日志会问dba什么原因导致的,借此机会把所有可能的原因整理出来的,希望可能给你一些排查方向。
[Note] Aborted connection 75782957 to db: ‘unconnected’ user: ‘root’ host: ‘localhost’ (Got timeout reading communication packets)
诊断方向
- error log
- general log
- show status like ‘%Aborted_%’
关注两个参数值的变化:Aborted_clients 和 Aborted_connects
详解
如果是客户端没法连接到服务端,Aborted_connects 值会增加,对应的可能性有:
- A client attempts to access a database but has no privileges for it. 一个没有权限的客户端对数据库发起访问。
- A client uses an incorrect password. 客户端使用了错误的密码。
- A connection packet does not contain the right information. 连接信息没有包含正确的信息。
- It takes more than connect_timeout seconds to obtain a connect packet. 获取连接数据包的时间超过了connect_timeout 秒。
如果这种情况发生了,可能暗示有人在入侵你的服务器.会有类似如下日志:
1 | [Note] Access denied for user 'drba'@'10.204.11.105' (using password: YES) |
如果客户端成功连接到服务器,稍后断开了或中断了,Aborted_clients 值会增加,并伴有日志:
1 | [Note] Aborted connection 75782957 to db: 'unconnected' user: 'root' host: 'localhost' (Got timeout reading communication packets) |
对应的可能性有:
- The client program did not call mysql_close() before exiting. 客户端程序在退出之前没有调用 mysql_close() 方法。
- The client had been sleeping more than wait_timeout or interactive_timeout seconds without issuing any requests to the server. 客户端闲置时间超过了 wait_timeout 或 interactive_timeout 秒。
- The client program ended abruptly in the middle of a data transfer. 数据传输过程中客户端突然断开。
其他可能导致 aborted connections 或 aborted clients 的原因有:
- The max_allowed_packet variable value is too small or queries require more memory than you have allocated for mysqld. max_allowed_packet 参数值设置过低或查询需要的内存超过了分配值。
- Use of Ethernet protocol with Linux, both half and full duplex. Some Linux Ethernet drivers have this bug. You should test for this bug by transferring a huge file using FTP between the client and server machines. If a transfer goes in burst-pause-burst-pause mode, you are experiencing a Linux duplex syndrome. Switch the duplex mode for both your network card and hub/switch to either full duplex or to half duplex and test the results to determine the best setting.
- A problem with the thread library that causes interrupts on reads.
- Badly configured TCP/IP.
- Faulty Ethernets, hubs, switches, cables, and so forth. This can be diagnosed properly only by replacing hardware hardware.
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 ASKDBA!
评论