今天在本机安装了三个zookeeper,分别为server1,server2,server3。
tickTime=2000 initLimit=5 syncLimit=2 dataDir=/Users/google/Work/Program/zookeeper/server1/zookeeper-3.4.6/data dataLogDir=/Users/google/Work/Program/zookeeper/server1/zookeeper-3.4.6/logs clientPort=4080 server.1=127.0.0.1:9991:7770 server.2=127.0.0.1:9992:7771 server.3=127.0.0.1:9993:7772
然后启动了server3的zkServer.sh,用server1的zkCli.sh去连接,结果报了如下错误:
2015-05-25 18:06:21,667 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Opening socket connection to server 127.0.0.1/127.0.0.1:4083. Will not attempt to authenticate using SASL (java.lang.SecurityException: ?????λ??¼????) JLine support is enabled 2015-05-25 18:06:21,678 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Socket connection established to 127.0.0.1/127.0.0.1:4083, initiating session 2015-05-25 18:06:21,690 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect [zk: 127.0.0.1:4083(CONNECTING) 0] 2015-05-25 18:06:23,045 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Opening socket connection to server 127.0.0.1/127.0.0.1:4083. Will not attempt to authenticate using SASL (java.lang.SecurityException: ?????λ??¼????) 2015-05-25 18:06:23,047 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Socket connection established to 127.0.0.1/127.0.0.1:4083, initiating session 2015-05-25 18:06:23,048 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect 2015-05-25 18:06:24,521 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Opening socket connection to server 127.0.0.1/127.0.0.1:4083. Will not attempt to authenticate using SASL (java.lang.SecurityException: ?????λ??¼????) 2015-05-25 18:06:24,522 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Socket connection established to 127.0.0.1/127.0.0.1:4083, initiating session 2015-05-25 18:06:24,523 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect 2015-05-25 18:06:25,942 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Opening socket connection to server 127.0.0.1/127.0.0.1:4083. Will not attempt to authenticate using SASL (java.lang.SecurityException: ?????λ??¼????) 2015-05-25 18:06:25,943 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Socket connection established to 127.0.0.1/127.0.0.1:4083, initiating session 2015-05-25 18:06:25,944 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect 2015-05-25 18:06:27,717 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Opening socket connection to server 127.0.0.1/127.0.0.1:4083. Will not attempt to authenticate using SASL (java.lang.SecurityException: ?????λ??¼????) 2015-05-25 18:06:27,717 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Socket connection established to 127.0.0.1/127.0.0.1:4083, initiating session 2015-05-25 18:06:27,718 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect 2015-05-25 18:06:29,608 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Opening socket connection to server 127.0.0.1/127.0.0.1:4083. Will not attempt to authenticate using SASL (java.lang.SecurityException: ?????λ??¼????) 2015-05-25 18:06:29,609 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Socket connection established to 127.0.0.1/127.0.0.1:4083, initiating session 2015-05-25 18:06:29,610 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect 2015-05-25 18:06:31,561 [myid:] - INFO [main-SendThread(127.0.0.1:4083):[email protected]] - Opening socket connection to server 127.0.0.1/127.0.0.1:4083. Will not attempt to authenticate using SASL (java.lang.SecurityException: ?????λ??¼????)
后来才搞明白,由于我在zoo.cfg中配置了3台机器,但是只启动了1台,zookeeper就会认为服务处于不可用状态。
zookeeper有个选举算法,当整个集群超过半数机器宕机,zookeeper会认为集群处于不可用状态。
所有,3台机器只启动一台无法连接,如果启动2台及以上就可以连接了。
时间: 2024-10-11 04:50:53