自学内容网 自学内容网

windows中安装zookeeper

https://zhuanlan.zhihu.com/p/692451839

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 属地山西


原文地址:https://blog.csdn.net/qq_27327261/article/details/139352957

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!