报错:Zookeeper Unable to open socket to localhost/0:0:0:0:0:0:0:1:2181

报错背景

单节点zokeeper

进入zookeeper客户端的时候报错:zkCli.sh

报错现象

2020-07-03 18:39:47,943 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1112] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2020-07-03 18:39:48,011 [myid:localhost:2181] - ERROR [main-SendThread(localhost:2181):ClientCnxnSocketNIO@287] - Unable to open socket to localhost/0:0:0:0:0:0:0:1:2181
2020-07-03 18:39:48,011 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1244] - Socket error occurred: localhost/0:0:0:0:0:0:0:1:2181: No route to host
[zk: localhost:2181(CONNECTING) 0] 2020-07-03 18:39:49,114 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1112] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
2020-07-03 18:39:49,114 [myid:localhost:2181] - ERROR [main-SendThread(localhost:2181):ClientCnxnSocketNIO@287] - Unable to open socket to localhost/0:0:0:0:0:0:0:1:2181
2020-07-03 18:39:49,114 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1244] - Socket error occurred: localhost/0:0:0:0:0:0:0:1:2181: No route to host
2020-07-03 18:39:50,216 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1112] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2020-07-03 18:39:50,217 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@959] - Socket connection established, initiating session, client: /127.0.0.1:57616, server: localhost/127.0.0.1:2181
2020-07-03 18:39:50,224 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1394] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x10005b5b80d0005, negotiated timeout = 160000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

报错原因

(1)zookeeper中少配了主机名的映射;

(2)hosts文件出现问题。

报错解决

先检查/etc/hosts文件中IP和主机名的映射是否正确;

再检查/opt/apache-zookeeper-3.5.6-bin/conf/目录下zoo.cfg文件有没有添加如下内容,如没有,则添上:

server.1=hadoop01:2888:3888
原文地址:https://www.cnblogs.com/chuijingjing/p/13580931.html