Zookeeper 集群

部署准备

至少三台服务器

安装

Zookeeper 安装包准备

Apache ZooKeeper 下载页面

配置文件修改

复制一份配置文件命名为 zoo.cfg

shell 复制代码
cp zoo_sample.cfg zoo.cfg

zoo.cfg

修改 dataDir。新增 server.1,server.2,server.3(x.x.x.x:2888:3888)

shell 复制代码
# 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=/home/bigdata/zookeeper/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.
#
# 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

server.1=bigdata1:2888:3888
server.2=bigdata2:2888:3888
server.3=bigdata3:2888:3888

分发配置文件到所有节点

shell 复制代码
# 复制 zookeeper 安装包的解压文件夹到所有的机器
scp -r apache-zookeeper-3.9.2-bin root@x.x.x.x:$PWD

设置myid

在每台机器的 dataDir 配置对应的目录下的 data 文件夹内创建 myid 文件,文件内容分别为 1, 2,3。机器的IP 和 myid 文件的内容 需要和配置文件中对应起来。

配置环境变量

shell 复制代码
export ZK_HOME=/usr/bigdata/apache-zookeeper-3.9.2-bin
export PATH=$PATH:$ZK_HOME/bin

启动集群

所有节点执行启动命令

shell 复制代码
zkServer.sh start
相关推荐
城管不管5 小时前
重生——第九次面试2026.8.13某车一面
分布式·ai·面试·职场和发展·rabbitmq
ly76896 小时前
分布式一致性算法详解:从 2PC、3PC 到 Paxos、Raft、ZAB
分布式·算法
珠***格7 小时前
通信链路全打通:西格电力四可装置的 4G/5G + 加密认证技术详解
大数据·数据库·分布式·5g·架构·能源
ACP广源盛139246256738 小时前
WAIC2026 国产算力浪潮@ACP#YLB3118 在算力矩阵中的存储定位与落地场景
大数据·人工智能·分布式·单片机·嵌入式硬件
蜀道山老天师11 小时前
ZABBIX分布式监控Proxy应用实践
分布式·zabbix
liudashuang201711 小时前
Kafka Producer 隐藏深坑:Sender 线程自阻塞(自死锁)导致 BufferExhaustedException 完整复盘
java·分布式·kafka·linq
rustfs13 小时前
GitLab 如何与 RustFS 集成?
分布式·rust·gitlab
Francek Chen13 小时前
【大数据处理与分析】数据仓库Hive:02 数据湖
大数据·数据仓库·hive·hadoop·分布式·数据分析
starzy199014 小时前
Spark 核心之二次排序、分组取 TopN 优化分析
大数据·分布式·spark
悦数图数据库14 小时前
千亿点边图谱建设,原生分布式图数据库如何避免单点瓶颈
数据库·分布式