zookeeper启动后报错Connection refused

zookeeper | 2019-09-13 10:02:39

我的zookeeper配置如下zoo.cfg:

tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/app/zookeeper/zookeeper1/data
dataLogDir=/usr/local/app/zookeeper/zookeeper1/log
clientPort=2181
server.1=192.168.1.10:2888:3888
server.2=192.168.1.10:4888:5888
server.3=192.168.1.10:6888:7888
server.4=192.168.1.10:8888:9888

启动zookeeper后,直接在客户端查看:

./zookeeper1/bin/zkCli.sh

报错拒绝连接:

2018-09-22 04:39:53,836 [myid:] - WARN  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1063] - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:286)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1041)

查看原因:

tail zookeeper1/zookeeper.out

显示:

2018-09-22 04:28:33,466 [myid:] - ERROR [main:QuorumPeerMain@85] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing /usr/local/app/zookeeper/zookeeper1/bin/../conf/zoo.cfg
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:121)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:101)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)
Caused by: java.lang.IllegalArgumentException: dataLogDir /usr/local/app/zookeeper/zookeeper1/log is missing.
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:247)
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:117)
... 2 more

说是没有/user/loocal/app/zookeeper/zookeeper1/log.确实是的,我只建了data文件夹,没有建log文件夹。导致报错,根本就没有起起来。

解决:

mkdir log

根据dataLogDir配置新建log文件夹就可以了。真实粗心大意了。


其他原因:

防火墙限制端口访问

zookeeper配置错误

java端配置错误



登录后即可回复 登录 | 注册
    
关注编程学问公众号