Zookeeper连接时KeeperException.java:102报错处理

报错内容

╭─root@esxi-kali /usr/share/zookeeper/bin  
╰─➤  ./zkCli.sh         
Connecting to localhost:2181
Welcome to ZooKeeper!
JLine support is enabled
[zk: localhost:2181(CONNECTING) 0] ls /
Exception in thread "main" org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:102)
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:54)
    at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1541)
    at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1569)
    at org.apache.zookeeper.ZooKeeperMain.processZKCmd(ZooKeeperMain.java:732)
    at org.apache.zookeeper.ZooKeeperMain.processCmd(ZooKeeperMain.java:600)
    at org.apache.zookeeper.ZooKeeperMain.executeLine(ZooKeeperMain.java:372)
    at org.apache.zookeeper.ZooKeeperMain.run(ZooKeeperMain.java:332)
    at org.apache.zookeeper.ZooKeeperMain.main(ZooKeeperMain.java:291)

此时使用的JAVA版本

╭─root@esxi-kali /usr/share/zookeeper/bin  
╰─➤  java -version                                                                                                                                         1 ↵
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

解决方法

修改zkEnv.sh文件中JAVA路径,使用openjdk

JAVA=/usr/lib/jvm/java-11-openjdk-amd64/bin/java

openjdk的JAVA版本

╭─root@esxi-kali /usr/share/zookeeper/bin  
╰─➤  /usr/lib/jvm/java-11-openjdk-amd64/bin/java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+1-Debian-1)
OpenJDK 64-Bit Server VM (build 11.0.3+1-Debian-1, mixed mode, sharing)

修改后不再报错

╭─root@esxi-kali /usr/share/zookeeper/bin  
╰─➤  ./zkCli.sh -server 192.168.137.200 ls /                                                                                                             130 ↵
Connecting to 192.168.137.200

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zookeeper]

你可能感兴趣的:(Zookeeper连接时KeeperException.java:102报错处理)