通过命令zkServer.sh start之后,显示STARTED
通过client测试报错 无法连接 连接关闭
Connecting to localhost:2181
2020-03-29 12:44:31,855 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.13-2d71af4dbe22557fda74f9a9b4309b15a7487f03, built on 06/29/2018 04:05 GMT
2020-03-29 12:44:31,857 [myid:] - INFO [main:Environment@100] - Client environment:host.name=backup01
2020-03-29 12:44:31,857 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_172
2020-03-29 12:44:31,858 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2020-03-29 12:44:31,858 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/local/java/jdk1.8.0_172/jre
2020-03-29 12:44:31,858 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/usr/local/hadoop/zookeeper/zookeeper-3.4.13/bin/../build/classes:/usr/local/hadoop/zookeeper/zookeeper-3.4.13/bin/../build/lib/*.jar:/usr/local/hadoop/zookeeper/zookeeper-3.4.13/bin/../lib/slf4j-log4j12-1.7.25.jar:/usr/local/hadoop/zookeeper/zookeeper-3.4.13/bin/../lib/slf4j-api-1.7.25.jar:/usr/local/hadoop/zookeeper/zookeeper-3.4.13/bin/../lib/netty-3.10.6.Final.jar:/usr/local/hadoop/zookeeper/zookeeper-3.4.13/bin/../lib/log4j-1.2.17.jar:/usr/local/hadoop/zookeeper/zookeeper-3.4.13/bin/../lib/jline-0.9.94.jar:/usr/local/hadoop/zookeeper/zookeeper-3.4.13/bin/../lib/audience-annotations-0.5.0.jar:/usr/local/hadoop/zookeeper/zookeeper-3.4.13/bin/../zookeeper-3.4.13.jar:/usr/local/hadoop/zookeeper/zookeeper-3.4.13/bin/../src/java/lib/*.jar:/usr/local/hadoop/zookeeper/zookeeper-3.4.13/bin/../conf:
2020-03-29 12:44:31,858 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2020-03-29 12:44:31,858 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2020-03-29 12:44:31,858 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA>
2020-03-29 12:44:31,858 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux
2020-03-29 12:44:31,858 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
2020-03-29 12:44:31,866 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-862.el7.x86_64
2020-03-29 12:44:31,866 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root
2020-03-29 12:44:31,866 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root
2020-03-29 12:44:31,866 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/usr/local/hadoop/zookeeper/zookeeper-3.4.13
2020-03-29 12:44:31,867 [myid:] - INFO [main:ZooKeeper@442] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@277050dc
2020-03-29 12:44:31,885 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1029] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
Welcome to ZooKeeper!
JLine support is enabled
2020-03-29 12:44:31,997 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2020-03-29 12:44:32,019 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1162] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
[zk: localhost:2181(CONNECTING) 0] 2020-03-29 12:44:33,522 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1029] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2020-03-29 12:44:33,525 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2020-03-29 12:44:33,530 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1162] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2020-03-29 12:44:35,480 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1029] - 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-03-29 12:44:35,481 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2020-03-29 12:44:35,485 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1162] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2020-03-29 12:44:37,542 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1029] - 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-03-29 12:44:37,542 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2020-03-29 12:44:37,544 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1162] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2020-03-29 12:44:38,754 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1029] - 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-03-29 12:44:38,754 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2020-03-29 12:44:38,756 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1162] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2020-03-29 12:44:40,281 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1029] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2020-03-29 12:44:40,281 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2020-03-29 12:44:40,283 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1162] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2020-03-29 12:44:41,886 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1029] - 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-03-29 12:44:41,887 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2020-03-29 12:44:41,890 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1162] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2020-03-29 12:44:43,559 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1029] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2020-03-29 12:44:43,560 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2020-03-29 12:44:43,562 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1162] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2020-03-29 12:44:45,106 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1029] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2020-03-29 12:44:45,107 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2020-03-29 12:44:45,109 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1162] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2020-03-29 12:44:47,098 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1029] - 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-03-29 12:44:47,098 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
我就很纳闷明明已经启动为啥查看状态报这个错呢
Error contacting service. It is probably not running
问题分析
我们可以通过bin目录下面的zookeeper.out来查看问题原因
为啥连接被拒绝
其实这个本身没有问题,因为这是集群的,要全部启动起来才能选举leader follower observer 因为还有两台没有启动 所以不能进行通信选举,我们只需要将另外两台启动起来就可以了
这个其实没有问题的,我以前的文章也写过,只是时间久了忘记了
这个以前集群安装启动的文章分布式Zookeeper安装搭建详解_ywl470812087的博客-CSDN博客
里面有个细节在第七步骤中 每台机器上分别启动,哎到这里我觉得自己太粗心大意,不知道各位有没有这样的情况,不知道这篇文章能不能帮到你