一,官网下载Zookeeper 的gz包,选择自己所需版本
二,解压下载的gz包,推荐7-Zip解压,解压过程提示有文件重名,点击“自动重命名”即可。解压后如图:
1,参考官网指导进行相关配置,进入conf 目录,将zoo_sample.cfg复制一份,重命名为zoo.cfg
2,修改修改zoo.cfg配置文件,自定义dataDir和dataLogDir路径,建议新建在解压包下,方便统一管理,新建的data和logs文件夹与之一一对应。
3,启动,点击bin目录下的zkServer.cmd(相当于启动一个服务)
随后点击zkCli.cmd(相当于启动一个客户端)
zoo.cfg配置文件相关配置项注释:
# The number of milliseconds of each tick,客户端与服务器或者服务器与服务器之间维持心跳,
#也就是每个tickTime时间就会发送一次心跳。通过心跳不仅能够用来监听机器的工作状态,
#还可以通过心跳来控制Flower跟Leader的通信时间,默认情况下FL的会话时常是心跳间隔的两倍,默认200秒
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
#集群中的follower服务器(F)与leader服务器(L)之间初始连接时能容忍的最多心跳数(tickTime的数量)
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
#集群中flower服务器(F)跟leader(L)服务器之间的请求和答应最多能容忍的心跳数。
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
# 该属性对应的目录是用来存放myid信息跟一些版本,日志,跟服务器唯一的ID信息等
dataDir=H:\software\apache-zookeeper-3.6.0-bin\apache-zookeeper-3.6.0-bin\data
dataLogDir=H:\software\apache-zookeeper-3.6.0-bin\apache-zookeeper-3.6.0-bin\logs
# the port at which the clients will connect
# 客户端连接的接口,客户端连接zookeeper服务器的端口,zookeeper会监听这个端口,接收客户端的请求访问!这个端口默认是2181
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
# 客户端的最大连接数量,默认60个
#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
## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
数据创建可参考:Zookeeper客户端使用详解