ZooInspector 连接不到 Zookeeper 的解决方法

Zookeeper正常启动后,在使用 ZooInspector 连接 Zookeeper 时出现了连接不上的问题。

[root@localhost bin]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.11/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

看打印出的信息是启动成功了,但就是连接不上。

决解方法:

这时查看一下Zookeeper的启动状态或日志文件:

[root@localhost 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.

可以看到发生了错误,并没有正常启动。

再看一下日志文件:

2017-12-13 17:56:37,514 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1161] - 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:QuorumPeer$QuorumServer@190] - Failed to resolve address: slave-03
java.net.UnknownHostException: slave-03: 未知的名称或服务
    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.apache.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:FastLeaderElection@854] - Notification time out: 60000
2017-12-13 17:56:38,277 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1035] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)

大概猜出来了,配置文件中有错误:

[root@localhost 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

文件中配置的是集群方式,现在是单机启动(不是单机启动不行,而是学习的过程中实验环境一直在变化)

你可能感兴趣的:(Zookeeper,Questions,从菜鸟到大神问题锦集)