首页 > 其他 > 详细

Zookeeper ipv6的坑

时间:2015-05-25 14:34:37      阅读:751      评论:0      收藏:0      [点我收藏+]

问题

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的坑

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!