zookeeper集群部署(单机 windows)

zookeeper集群部署(单机 windows)目录


文章目录


一、下载解压zookeeper


解压后修改文件夹名称为zookeeper1 并复制另外两个zookeeper修改对应名称

注意:zookeeper集群数量推荐最好是奇数个,这是因为zookeeper集群需要选举leader节点,半数以上的会被选举为Leader节点,且集群半数以上存活,代表zookeeper集群存活。如果集群数量是偶数的话,容易出现选举的时候投票持平导致选举失败或者延迟。

二、修改zookeeper配置

1.复制zookeeper下面的conf文件下的zoo_sample.cfg文件出来修改为zoo.cfg

2.修改zoo.cfg的dataDir(zookeeper数据文件存放路径,修改到每一个zookeeper下面的data文件夹下面,没有就新建一个)

3.修改配置文件路径,记住一定要两个\\

4.添加myid文件,myid文件是用来唯一标识每个zookeeper实例在集群中的id。

1.打开cmd cd到每个集群的data路径里面

c 复制代码
C:\Users\86135>cd D:\zookeeper\zookeeper1\data
C:\Users\86135>D:
D:\zookeeper\zookeeper1\data>echo 1 > myid
D:\zookeeper\zookeeper1\data>

2.用nodepad++打开myid 删除空格

3.zookeeper2 zookeeper3也是一样的方式,但是dataDir要改成自的data文件路径,myid分别是2和3 这里如果有集群配置重复 会出现启动失败

四、zoo.cfg配置文件添加其他集群的信息

c 复制代码
# 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:\\zookeeper\\zookeeper1\\data
# 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

server.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890

clientPort zookeeper1-zookeeper3要修改成2181 2182 2183不同端口,因为是单机防止端口占用冲突

server后面第一个数字1-3代表刚才配置的myid的数字,zookeeper集群中有哪些服务器,后面ip是每个集群的ip地址,因为是单机所以都是localhost,后面的第一个端口是通信端口,第二个是选举端口

五、启动集群

1.cmd进每个zookeeer下面的bin目录,启动zkServer脚本

启动成功

相关推荐
武子康2 小时前
Java-72 深入浅出 RPC Dubbo 上手 生产者模块详解
java·spring boot·分布式·后端·rpc·dubbo·nio
橘子在努力5 小时前
【橘子分布式】Thrift RPC(理论篇)
分布式·网络协议·rpc
liulilittle7 小时前
.NET ExpandoObject 技术原理解析
开发语言·网络·windows·c#·.net·net·动态编程
lifallen7 小时前
Kafka 时间轮深度解析:如何O(1)处理定时任务
java·数据结构·分布式·后端·算法·kafka
沈健_算法小生10 小时前
基于SpringBoot3集成Kafka集群
分布式·kafka·linq
Swift社区10 小时前
ELK、Loki、Kafka 三种日志告警联动方案全解析(附实战 Demo)
分布式·elk·kafka
cpsvps13 小时前
VR协作海外云:跨国企业沉浸式办公解决方案
windows·架构·vr·etw事件
义薄云天us14 小时前
019_工具集成与外部API调用
数据库·人工智能·windows·microsoft·claude code
RainbowSea14 小时前
安装win10出现“计算机意外的重新启动或遇到错误。Windows安装无法继续。若要安装Windows,请单击“确定”重新启动计算机,然后安装系统。”
windows·后端
bug攻城狮15 小时前
理解Grafana中`X-Scope-OrgID`的作用与配置
windows·grafana