下载
官网:https://zookeeper.apache.org/releases.html
我下载的是3.6.1版本。主要要下载文件名带有bin的包。不然就会遇到后续提到的错误。
安装
将压缩包解压后放到一个目录下,将zoo_sample.cfg文件复制一份,修改名称为zoo.cfg
配置一下数据和日志文件的存放路径,也就是dataDir和dataLogDir这两个属性,配置文件内容如下。
# 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=D:\\ProgramData\\apache-zookeeper-3.6.1\\data
dataLogDir=D:\\ProgramData\\apache-zookeeper-3.6.1\\log
# 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
## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
运行
进入bin目录,运行zkServer.cmd启动服务,再运行zkCli.cmd验证是否安装成功。
安装成功
遇到问题
运行zkServer.cmd遇到如下报错信息:
错误: 找不到或无法加载主类 org.apache.zookeeper.server.quorum.QuorumPeerMain
从3.5.5版本开始,带有bin名称的包是可以直接使用的里面有编译后的二进制的包。重新下载后再操作即可。
参考链接
windows环境下安装zookeeper教程详解(单机版)
zookeeper-3.5.5安装报错:找不到或无法加载主类 org.apache.zookeeper.server.quorum.QuorumPeerMain