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
相关推荐
ABB自动化19 分钟前
ABB 500CIM06 (1MRB150077R0111) | REB500 通信接口
大数据·分布式·系统架构·系统安全·模块测试·plc 控制器
ZENERGY-众壹35 分钟前
告别本地工控机:分布式光伏 SCADA 架构如何实现云边协同
分布式·架构·光伏运维·能源数字化·电站监控
code_slave(码畜)42 分钟前
微服务架构落地:读写分离架构 —— 主从延迟引发的“刚开单查不到”灾难与破局
spring boot·分布式·spring cloud·微服务·云原生·架构·读写分离
JAVA_AI人工智能项目实战2 小时前
分布式大模型训练_学习笔记
人工智能·分布式·语言模型·自然语言处理
星夜孤帆3 小时前
Redis缓存击穿与分布式锁实战:专栏目录、源码与实验说明
redis·分布式·缓存
yyk333244 小时前
Spark介绍
大数据·分布式·spark
成为你的宁宁4 小时前
【基于 SSH 与 JNLP 协议的 Jenkins 分布式构建方案】
分布式·jenkins
PingCAP20 小时前
善战者无赫赫之功:消费金融核心系统的数据库选型与升级路径
数据库·分布式·架构
库库的数据库笔记21 小时前
金融核心交易系统的数据库国产信创改造该如何做?
大数据·数据库·分布式·mysql·oracle·金融·数据库架构
爱吃火鸡面呀1 天前
深入理解 Spark RDD:五大特性与实战解析
大数据·分布式·spark