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.

转载于:https://www.cnblogs.com/ttssrs/p/6677451.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值