美文网首页
KeeperErrorCode = ConnectionLoss

KeeperErrorCode = ConnectionLoss

作者: _孙行者_ | 来源:发表于2022-06-09 11:40 被阅读0次

    错误信息如下:

    Exception in thread "main" org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /test 
         at org.apache.zookeeper.KeeperException.create(KeeperException.java:99) 
         at org.apache.zookeeper.KeeperException.create(KeeperException.java:51) 
         at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1041) 
         at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1069) 
         at cn.zhang.bigdata.zk.ZooKeeperTest.main(ZooKeeperTest.java:11)
    

    网上也说了很多情况:

    1、连接还没有创建完成,就操作节点就会报异常?(最多,而且千篇一律,都一样)
    2、用最新的jar试一下?(试了不好用)
    3、防火墙没有关闭?(我的已经关闭)

    解决方法

    一) 操作太快 , 加下延时

     // 将时间改为 15秒,即可 
     ZooKeeper zk = new ZooKeeper("10.0.0.11:2181", 15000, null); 
    

    二) 网络不通, 是不是根本连不上zk ?

    [root@tom zookeeper] bin/zkCli.sh -server 10.12.1.123:2182
    ....
    ....
    2019-12-31 15:58:34,868 [myid:] - INFO  [main-SendThread(10.12.1.123:2182):ClientCnxn$SendThread@876] - Socket connection established to 10.12.1.123/10.12.1.123:2182, initiating session
    [zk: 10.12.1.123:2182(CONNECTING) 0] 2019-12-31 15:58:36,150 [myid:] - INFO  [main-SendThread(10.12.1.123:2182):ClientCnxn$SendThread@1158] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
    

    在通过zkCli.sh -server host1:port1,host2:port2,host3:port3形式连接zk时,前面的不可用会自动连接下一个,但是zkui在第一个不可用时好像没有继续连接下面的zk地址,导致zkui连接zk失败,打开web界面出现ConnectionLoss的情况。

    相关文章

      网友评论

          本文标题:KeeperErrorCode = ConnectionLoss

          本文链接:https://www.haomeiwen.com/subject/nisemrtx.html