当前位置:   article > 正文

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

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);
    }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/632708
推荐阅读
相关标签
  

闽ICP备14008679号