Communication Errors and Aborted Connections
阿新 • • 發佈:2019-08-26
很多開發看到如下日誌會問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
如果這種情況發生了,可能暗示有人在入侵你的伺服器.會有類似如下日誌:
[Note] Access denied for user 'drba'@'10.204.11.105' (using password: YES)
如果客戶端成功連線到伺服器,稍後斷開了或中斷了,Aborted_clients 值會增加,並伴有日誌:
[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 hardw