Download 下载
选择最新稳定版下载,下载后解压
示例配置文件
执行 cd命令到根目录下,cd 到 conf 目录下,可以看到一个zoo_sample.cfg示例配置文件。
cat zoo_sample.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=/tmp/zookeeper
# 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.
#
# https://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.httpHost=0.0.0.0
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
tickTime :ZooKeeper 使用的基本时间单位(以毫秒为单位)。它用于进行心跳,最小会话超时将是tickTime 的两倍。
dataDir :存储内存数据库快照的位置,除非另有指定,否则存储数据库更新的事务日志。
clientPort : 监听客户端连接的端口
创建自己的配置文件
vim zoo.cfg
填写文件内容
tickTime=2000
dataDir=~/zookeeper/data
clientPort=2181
启动 zookeeper
bin/zkServer.sh start
zkCli连接
bin/zkCli.sh -server 127.0.0.1:2181
zkcli测试
评论区