今天搭建了一个zookeeper集群,分别为server1,server2,server3。
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
server.1=172.16.1.159:2888:3888
server.2=172.16.1.123:2888:3888
server.3=172.16.1.22:2888:3888
在启动zkCli.sh 的时候就出现了日志信息无限重复打印,内容如下:
2017-10-23 10:57:14,816 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:15,036 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181
2017-10-23 10:57:15,036 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2017-10-23 10:57:15,037 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:15,663 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/127.0.0.1:2181
2017-10-23 10:57:15,663 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2017-10-23 10:57:15,664 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:16,190 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181
2017-10-23 10:57:16,190 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2017-10-23 10:57:16,191 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:16,358 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/127.0.0.1:2181
2017-10-23 10:57:16,359 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2017-10-23 10:57:16,359 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:16,773 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181
2017-10-23 10:57:16,773 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2017-10-23 10:57:16,774 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:17,025 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/127.0.0.1:2181
2017-10-23 10:57:17,025 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2017-10-23 10:57:17,026 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:17,300 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181
2017-10-23 10:57:17,300 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2017-10-23 10:57:17,301 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:18,229 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/127.0.0.1:2181
2017-10-23 10:57:18,230 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2017-10-23 10:57:18,231 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:18,747 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181
2017-10-23 10:57:18,747 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2017-10-23 10:57:18,748 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:19,451 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/127.0.0.1:2181
2017-10-23 10:57:19,452 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2017-10-23 10:57:19,453 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:20,012 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181
2017-10-23 10:57:20,012 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2017-10-23 10:57:20,013 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:20,947 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/127.0.0.1:2181
2017-10-23 10:57:20,947 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2017-10-23 10:57:20,948 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:21,907 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181
2017-10-23 10:57:21,907 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2017-10-23 10:57:21,908 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:22,545 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/127.0.0.1:2181
2017-10-23 10:57:22,545 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2017-10-23 10:57:22,546 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:22,764 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181
2017-10-23 10:57:22,765 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2017-10-23 10:57:22,765 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:23,370 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/127.0.0.1:2181
2017-10-23 10:57:23,371 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2017-10-23 10:57:23,372 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:24,093 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181
2017-10-23 10:57:24,094 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2017-10-23 10:57:24,094 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2017-10-23 10:57:25,148 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1058] - Opening socket connection to server localhost/127.0.0.1:2181
2017-10-23 10:57:25,148 - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/127.0.0.1:2181, initiating session
使用dubbo添加服务的时候也添加不上,在网上查找原因,说是可能jar包版本与zookeeper版本不一致,然后去核对版本,发现版本号一致的情况下也无法注册服务。之后又去核对myid文件,发现也没有错误。
后来才搞明白,由于我在zoo.cfg中配置了3台机器,但是只启动了1台,zookeeper就会认为服务处于不可用状态。
zookeeper有个选举算法,当整个集群超过半数机器宕机,zookeeper会认为集群处于不可用状态。
所以,3台机器启动1台无法连接,如果启动2台及以上就可以连接了。