zookeeper入门简介

1、安装(Linux,集群,3台机器

  1. java环境,安装jdk,至少需要1.6版本
  2. 下载zookeeper,进入zookeeper/conf目录,拷贝zoo_sample.cfg,重命名为zoo.cfg,配置如下
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/usr/local/zookeeper-3.4.6/data
dataLogDir=/usr/local/zookeeper-3.4.6/dataLog
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=192.168.236.128:2888:3888
server.3=192.168.236.130:2888:3888
server.5=192.168.236.137:2888:3888

然后在dataDir对应的目录中,新建myid文件填入ID值,对应如下图server后面的数字

完了之后通过bin目录下面的zkServer.sh脚本可以开启和关闭服务,通过ps命令可以验证zk开启成功,通过bin目录下面的zkCli.sh脚本可以开启zk的命令终端,然后使用zk命令操作

Java API操作

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容