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 分钟前
Ceph 分布式存储实战(一):架构入门与 cephadm 集群部署
分布式·ceph·架构·cephadm
j7~29 分钟前
【Redis】《一文走完服务端高并发架构演进:从单机架构到 K8S 容器编排》
分布式·架构演进·服务端高并发分布式结构演进之路·架构基本概念·架构评价指标
Flynt1 小时前
把 bug tracker 塞进 git 仓库,同步和冲突怎么解决?我把 git-bug 拆开实测了一遍
分布式·git·开源
灯澜忆梦18 小时前
【RabbitMQ #3】 | Go 客户端 + SpringAMQP
分布式·golang·rabbitmq
Q26433650231 天前
【有源码】基于Spark的电商客户细分与盈利洞察分析系统-面向精准营销的电商客户细分模型构建与盈利能力可视化研究
大数据·hadoop·分布式·数据挖掘·数据分析·spark·毕业设计
新思维软件1 天前
基于无线传输的地衡系统:三节点 LoRa 组网与 MQTT 上云的分布式称重方案
分布式·stm32·单片机·嵌入式硬件·物联网·物联网开发
俊哥大数据1 天前
Flink1.20.3 实时消费 Kafka 数据并解析入湖 Paimon1.4.2 全流程实战
分布式·flink·kafka·数据湖·paimon
宸津-代码粉碎机1 天前
OpenAI 连夜迎战 Grok Bot 和 Muse:AI 智能体从 “会聊天” 到 “能办事”,现在入场还来得及吗
java·大数据·人工智能·分布式·python
程序猿乐锅1 天前
【黑马点评 | 第八篇】Redisson分布式锁
java·数据库·spring boot·redis·分布式·spring·缓存
灯澜忆梦1 天前
【RabbitMQ #7】 | 消息转换器
分布式·rabbitmq·ruby