logstash-output-jdbc遇到connection is not available,request time out after 10000ms的問題解決


上一篇logstash-output-jdbc使用中提到“運行bin/logstash -f test.conf時可能提示注冊插件失敗”,通過分析詳細的錯誤日志,發現其赫然寫着“connection is not available,request time out after 10000ms”,原來是mysql連接的問題,插件注冊失敗只是表象。

由於沒有在logstash所在的機器A安裝mysql,而是通過mysql connector 的jar包(logstash conf文件里指定了jar報路徑),所以沒有辦法測試A到數據庫機器B的連接是否成功,嘗試過增加mysql connection_timeout的時間到300s,發現錯誤還是request time out after 10000ms,說明jar里有自己的時間設置。

百度良久,最后在mysql的my.ini文件(默認C:\PragramData\MySQL\MySQLServer 5.7目錄下)中增加skip-name-resolve,重啟mysql服務后,問題解決。原因是

MySQL處理用戶連接時進行如下過程來驗證用戶的合法性(參考http://www.cnblogs.com/timeship/archive/2013/02/28/2937730.html):

When a new client connects to mysqld, mysqld spawns a new thread to handle the request. This thread first checks whether the host name is in the host name cache. If not, the thread attempts to resolve the host name: 
The thread takes the IP address and resolves it to a host name (using gethostbyaddr()). It then takes that host name and resolves it back to the IP address (using gethostbyname()) and compares to ensure it is the original IP address.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM