ZooKeeper学习和使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Bactryki28/article/details/75010316

网上已经有很多介绍Zookeeper的文章和以及详细的安装配置过程,本文也罗列了几篇写得不错的,作为使用手册吧。

官方文档:Zookeeper总览
分布式服务框架 Zookeeper – 管理分布式环境中的数据

ZooKeeper的学习笔记:
http://agapple.iteye.com/blog/1111377
http://agapple.iteye.com/blog/1112032
http://agapple.iteye.com/blog/1292129
http://agapple.iteye.com/blog/1184023
http://agapple.iteye.com/blog/1184040

关于Watcher
http://luzengyi.blog.163.com/blog/static/529188201064113744373/
http://luzengyi.blog.163.com/blog/static/529188201061155444869/

ZooKeeper运维
http://blog.csdn.net/hengyunabc/article/details/19006911

ZooKeeper管理员工具
http://zookeeper.apache.org/doc/trunk/zookeeperAdmin.html#sc_supportedPlatforms

Java连接ZooKeper客户端失败的问题

java.net.ConnectException: Connection timed out: no further information
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /zktest
    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:1102)
    at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1130)
    at com.lz.zookeeper.Test1.createZnode(Test1.java:21)
    at com.lz.zookeeper.Test1.main(Test1.java:53)

是因为服务端运行的防火墙没有开放2181端口导致。

开放2181端口:

firewall-cmd --zone=public --add-port=2181/tcp --permanent

重载防火墙:

firewall-cmd --reload

初学真的遇到很多坑,且慢慢填了!

猜你喜欢

转载自blog.csdn.net/Bactryki28/article/details/75010316