ZooKeeper运行报错KeeperErrorCode = NoNode for .....

2021/12/4 20:16:43

本文主要是介绍ZooKeeper运行报错KeeperErrorCode = NoNode for .....,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

   最近遇到一个很尴尬的报错,org.apache.zookeeper.KeeperException$NoAuthException: KeeperErrorCode KeeperErrorCode = NoNode for (节点路径)。

java.io.IOException: Failed to process transaction type: 1 error: KeeperErrorCode = NoNode for /cloudera_manager_zookeeper_canary
         at org.apache.zookeeper.server.persistence.FileTxnSnapLog.restore(FileTxnSnapLog.java:188)
         at org.apache.zookeeper.server.ZKDatabase.loadDataBase(ZKDatabase.java:223)
         at org.apache.zookeeper.server.quorum.QuorumPeer.loadDataBase(QuorumPeer.java:417)
         at org.apache.zookeeper.server.quorum.QuorumPeer.start(QuorumPeer.java:409)
         at org.apache.zookeeper.server.quorum.QuorumPeerMain.runFromConfig(QuorumPeerMain.java:156)
         at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:116)
         at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:79)
 Caused by: org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /cloudera_manager_zookeeper_canary
         at org.apache.zookeeper.server.persistence.FileTxnSnapLog.processTransaction(FileTxnSnapLog.java:250)
         at org.apache.zookeeper.server.persistence.FileTxnSnapLog.restore(FileTxnSnapLog.java:186)

    百度后发现关闭ZooKeeper,删除你自己设定的dataDir路径下的version-2文件夹,然后重启即可。

    随着进一步的了解,我突然顿悟!!!

    在每次新建一个节点时,一定要判断该节点(路径)是否存在,因为在ZooKeeper中路径使唯一的,所以当在该路径下已有节点时,继续往当前路径上新建节点就会报这个错。所以删除缓存的version-2文件夹其实就是删除了已经create的节点。

    if (null==zk.exists("/root", false)) {
        zk.create("/root", "测试".getBytes(),acls , CreateMode.PERSISTENT);
    }



这篇关于ZooKeeper运行报错KeeperErrorCode = NoNode for .....的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程