码迷,mamicode.com
首页 > 其他好文 > 详细

Zookeeper ipv6的坑

时间:2015-05-25 14:35:44      阅读:362      评论:0      收藏:0      [点我收藏+]

标签:zookeeper   debug   

问题

zookeeper抛这样的错误:

 [main-SendThread(localhost:2000)] ERROR org.apache.zookeeper.ClientCnxn  - Unable to open socket to localhost/0:0:0:0:0:0:0:1:2181
4549 [main-SendThread(localhost:2000)] WARN  org.apache.zookeeper.ClientCnxn  - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.SocketException: Address family not supported by protocol family: connect
    at sun.nio.ch.Net.connect(Native Method)
    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:532)
    at org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:1071)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1104)

注意到

localhost/0:0:0:0:0:0:0:1

localhost被翻译成了0:0:0:0:0:0:0:1。

打开/etc/hosts,可以看到127.0.0.1和::1都有localhost的配置:
技术分享

显然在打开ipv6的情况下,localhost的值被后者覆盖了,所以zk抛错了。

解决

两个简单的解决方案:
1. 关闭ipv6。
2. 在hosts里,把::1对应的localhost改个别名,比如localhost-ipv6。

全文完 :)

Zookeeper ipv6的坑

标签:zookeeper   debug   

原文地址:http://blog.csdn.net/pelick/article/details/45968941

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!