1. 程式人生 > >Communication Errors and Aborted Connections

Communication Errors and Aborted Connections

 很多開發看到如下日誌會問dba為什麼,藉此機會把所有可能的原因整理出來的,希望可能給你一些排查方向。

[Note] Aborted connection 75782957 to db: 'unconnected' user: 'root' host: 'localhost' (Got timeout reading communication packets)

診斷方向

  1. error log
  2. general log
  3. show status like '%Aborted_%' 

         關注兩個引數值的變化:Aborted_clients 和 Aborted_connects

詳解

如果是客戶端沒法連線到服務端,Aborted_connects 值會增加,對應的可能性有:

  1. A client attempts to access a database but has no privileges for it. 一個沒有許可權的客戶端對資料庫發起訪問。
  2. A client uses an incorrect password. 客戶端使用了錯誤的密碼。
  3. A connection packet does not contain the right information. 連線資訊沒有包含正確的資訊。
  4. It takes more than connect_timeout
     seconds to obtain a connect packet. 獲取連線資料包的時間超過了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)


對應的可能性有:

  1. The client program did not call mysql_close() before exiting.  客戶端程式在退出之前沒有呼叫 mysql_close() 方法。
  2. The client had been sleeping more than wait_timeout or interactive_timeout seconds without issuing any requests to the server. 客戶端閒置時間超過了 wait_timeout  或 interactive_timeout 秒。
  3. The client program ended abruptly in the middle of a data transfer. 資料傳輸過程中客戶端突然斷開。

其他可能導致  aborted connections 或 aborted clients 的原因有:

  1. The max_allowed_packet variable value is too small or queries require more memory than you have allocated for mysqld. max_allowed_packet 引數值設定過低或查詢需要的記憶體超過了分配值。
  2. 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. 
  3. A problem with the thread library that causes interrupts on reads.
  4. Badly configured TCP/IP.
  5. Faulty Ethernets, hubs, switches, cables, and so forth. This can be diagnosed properly only by replacing hardw