解决"org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /io.vertx

一、异常描述

SLF4J: This version of SLF4J requires log4j version 1.2.12 or later. See also http://www.slf4j.org/codes.html#log4j_version
log4j:WARN No appenders could be found for logger (org.apache.zookeeper.ZooKeeper).
log4j:WARN Please initialize the log4j system properly.
watcher received event

Exception in thread "main" org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /io.vertx/syncMap/test
at org.apache.zookeeper.KeeperException.create(KeeperException.java:114)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:54)
at org.apache.zookeeper.ZooKeeper.getData(ZooKeeper.java:1221)
at org.apache.zookeeper.ZooKeeper.getData(ZooKeeper.java:1250)
at zookeeper.BaseZookeeper.getData(BaseZookeeper.java:57)
at zookeeper.ZookeepClient.main(ZookeepClient.java:30)

二、解决方法

1. 通过ssh客户端的zk客户端命令连接zk服务端(参考命令:zkCli.sh -server localhost:2181,配置zookeeper服务端)

[root@raid2t shell]# zkCli.sh -server localhost:2181
Connecting to localhost:2181
2018-12-01 22:31:06,134 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2018-12-01 22:31:06,136 [myid:] - INFO [main:Environment@100] - Client environment:host.name=
2018-12-01 22:31:06,136 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.7.0_79
2018-12-01 22:31:06,137 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2018-12-01 22:31:06,137 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/home/jdk7/jre
2018-12-01 22:31:06,137 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/app/zookeeper-3.4.6/bin/../build/classes:/app/zookeeper-3.4.6/bin/../build/lib/.jar:/app/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/app/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/app/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/app/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/app/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/app/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/app/zookeeper-3.4.6/bin/../src/java/lib/.jar:/app/zookeeper-3.4.6/bin/../conf:.:/home/jdk7/lib/dt.jar:/home/jdk7/lib/tools.jar:/home/jdk7/jre/lib
2018-12-01 22:31:06,137 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2018-12-01 22:31:06,138 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2018-12-01 22:31:06,138 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=
2018-12-01 22:31:06,138 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux
2018-12-01 22:31:06,138 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
2018-12-01 22:31:06,138 [myid:] - INFO [main:Environment@100] - Client environment:os.version=2.6.32-642.el6.x86_64
2018-12-01 22:31:06,138 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root
2018-12-01 22:31:06,138 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root
2018-12-01 22:31:06,138 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/root/shell
2018-12-01 22:31:06,139 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@28807653
Welcome to ZooKeeper!
2018-12-01 22:31:06,156 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@975] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2018-12-01 22:31:06,162 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@852] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2018-12-01 22:31:06,167 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1235] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x16769e5a5940003, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

2.创建/master数据Node节点(参考命令:create /io.vertx syncMap test

3.重新运行ZookeepClient客户端类,问题解决了,运行后日志如下

SLF4J: This version of SLF4J requires log4j version 1.2.12 or later. See also http://www.slf4j.org/codes.html#log4j_version
log4j:WARN No appenders could be found for logger (org.apache.zookeeper.ZooKeeper).
log4j:WARN Please initialize the log4j system properly.
watcher received event

上一篇:Python3 - 字符串转换为日期


下一篇:中国工业环保产业“十四五”规划及未来发展趋势报告2022~2027年