報錯背景
單節點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