当前位置:   article > 正文

ZooKeeper的Java API客户端异常:org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorC_org.apache.zookeeper.keeperexception$operationtime

org.apache.zookeeper.keeperexception$operationtimeoutexception: keepererrorc

 

log4j:WARN No appenders could be found for logger (org.apache.zookeeper.ZooKeeper).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /servers/server
at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:783)
at cn.itcast.bigdata.zkdist.DistributedServer.registerServer(DistributedServer.java:46)

 

at cn.itcast.bigdata.zkdist.DistributedServer.main(DistributedServer.java:68)

网上常见的解决方法是:关闭防火墙

但是防火墙就是处于关闭状态,所以此方法不可用。

经过调试发现 private static final int sessionTimeout = 10000 中设置的sessionTimeout值太小,应增大此值,问题解决。

解释:sessionTimeout是会话超时时间,也就是当一个zookeeper超过该时间没有心跳,则认为该节点故障。所以,如果此值小于zookeeper的创建时间,则当zookeeper还未来得及创建连接,会话时间已到,因此抛出异常认为该节点故障。

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

闽ICP备14008679号