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
相关推荐
喂完待续4 小时前
Apache Hudi:数据湖的实时革命
大数据·数据仓库·分布式·架构·apache·数据库架构
yh云想12 小时前
《从入门到精通:Kafka核心原理全解析》
分布式·kafka
ModelWhale17 小时前
“大模型”技术专栏 | 浅谈基于 Kubernetes 的 LLM 分布式推理框架架构:概览
分布式·kubernetes·大模型
愿天堂没有C++17 小时前
C++——分布式
分布式
UPToZ18 小时前
【Docker】搭建一个高性能的分布式对象存储服务 - MinIO
分布式·docker·容器
路多辛1 天前
Debian新一代的APT软件源配置文件格式DEB822详解
linux·运维·ubuntu·debian
前端世界1 天前
鸿蒙任务调度机制深度解析:优先级、时间片、多核与分布式的流畅秘密
分布式·华为·harmonyos
A尘埃1 天前
金融项目高可用分布式TCC-Transaction(开源框架)
分布式·金融·开源
夜影风1 天前
RabbitMQ核心架构与应用
分布式·架构·rabbitmq
电商API_180079052472 天前
大规模调用淘宝商品详情 API 的分布式请求调度实践
服务器·数据库·分布式·爬虫