After Zookeeper started normally, when using ZooInspector to connect to Zookeeper, there was a problem of not being able to connect.
[[email protected] bin]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.11/bin/.. /conf/zoo.cfg
Starting zookeeper ... STARTED
The information printed is that the startup is successful, but it just cannot be connected.
Solution:
Check the startup status or log file of Zookeeper at this time:
[[emailprotected] bin ]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.11/bin/../conf/zoo.cfg
Error contacting service . It is probably not running.
You can see that an error has occurred and it did not start normally.
Look at the log file again:
2017-12-13 17:56:37,514 [myid:]-INFO [main-SendThread(localhost:2181):[emailprotected] ]-Unable to read additional data from server sessionid 0x100000438d60007, likely server has closed socket, closing socket connection and attempting reconnect
2017-12-13 17:56:37,668 [myid:1]-WARN [QuorumPeer[myid= 1]/0:0:0:0:0:0:0:0:2181:[emailprotected]]-Failed to resolve address: slave-03
java.net.UnknownHostException: slave-03: unknown Name or service
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
at java.net.InetAddress .getAddressesFromNameService(InetAddress.java:1323)
at java.net.InetAddress.getAllByName0(InetAddress.java:1276)
at java.net.InetAddress.getAllByName(InetAddress.java:1192)
at java.net.InetAddress.getAllByName(InetAddress.java:1126)
at java.net.InetAddress.getByName(InetAddress.java:1076)
at org.apac he.zookeeper.server.quorum.QuorumPeer$QuorumServer.recreateSocketAddresses(QuorumPeer.java:180)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:591)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:610)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:845)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:957)
2017-12-13 17:56:37,669 [myid:1]-INFO [QuorumPeer[myid=1]/0 :0:0:0:0:0:0:0:2181:[emailprotected]]-Notification time out: 60000
2017-12-13 17:56:38,277 [myid:]-INFO [main -SendThread(localhost:2181):[emailprotected]]-Opening socket connection to server localhost/0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
I guessed it, there is an error in the configuration file:
[[emailprotected] bin]# vim ../conf/zoo.cfg
tickTime=2000
dataDir=/usr/local/zookeeper-3.4. 11/data
dataLogDir=/usr/local/zookeeper-3.4.11/log
clientPort=2181
initLimit=5
syncLimit=2
server.1= slave-01:2888:3888
server.2=slave-02:2888:3888
server.3=slave-03:2888:3888
The cluster is configured in the file The way, now it is a stand-alone startup (not that the stand-alone startup does not work, but the experimental environment has been changing during the learning process)