启动zookeeper的问题

时间:2015-07-20 07:25:25

标签: java runtime-error apache-zookeeper

我在启动zookeeper时面临一个奇怪的问题。每次我启动zookeeper时,它都会开始运行,但是它会被绑定到端口,因为我可以重新启动它。以下是我的zoo.cfg文件

    tickTime=2000
    initLimit=10
    syncLimit=5
    dataDir=/var/zookeeper
    clientPort=2181

此外,当我尝试通过我的java文件连接并执行zoo keeper命令时,我收到以下错误

15/07/20 12:27:46 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
15/07/20 12:27:46 WARN zookeeper.ClientCnxn: 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:739)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)
java.lang.RuntimeException: error in updating node :/testnode/test result : CONNECTION_LOSS

有人可以解释一下,为什么它会重新连接并帮助我排除这个错误?

1 个答案:

答案 0 :(得分:0)

这是因为我的java home未正确导出。它指向jdk目录中的bin,不应该是这种情况。所以在将java home导出到jdk的根目录后解决了问题