https://zhuanlan.zhihu.com/p/692451839
【zookeeper】在Windows上启动zookeeper_windows启动zk-CSDN博客
Index of /apache/zookeeper/zookeeper-3.9.2
Index of /apache/zookeeper/zookeeper-3.9.2
Zookeeper的应用场景
1、配置管理
2、服务注册中心
3、主从协调
4、分布式锁。(客户端在一个节点下创建有序节点,如果分配的节点号最小,则获取锁,没有获取到锁的客户端监听前一节点变化,判断自己是否是最小的节点来获取锁)
Windows版本的zookeeper用于学习还是很方便的,毕竟个人电脑操作系统大部分都是windows的。
下载
下载地址:点击下载
下载后文件名:apache-zookeeper-3.9.2-bin.tar.gz
解压到文件夹
例如:F:\devtool\apache-zookeeper-3.9.2-bin
修改配置文件
将%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=/tmp/zookeeper
dataDir=F:\devtool\apache-zookeeper-3.9.2-bin\data
dataLogDir=F:\devtool\apache-zookeeper-3.9.2-bin\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.
#
# 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
新增文件夹
对应上图配置的文件夹
配置环境变量
为了使用zookeeper命令方便,将zookeeper的bin文件夹加入到环境变量中
启动服务
启动客户端
测试
在客户端控制台创建节点
发布于 2024-04-14 22:27・IP 属地山西