目 录CONTENT

文章目录

Zookeeper 集群环境搭建

BKUN
2023-11-23 / 0 评论 / 0 点赞 / 807 阅读 / 329 字

1、准备

1.1、官网下载Zookeeper安装包

apache-zookeeper-3.8.0-bin.tar.gz

1.2、安装JDK,并配置环境变量

2、环境搭建

2.1 解压Zookeeper安装包

tar -zvxf apache-zookeeper-3.8.0-bin.tar.gz

2.2 创建Zookeeper Data目录

mkdir -p /app/apache-zookeeper-3.8.0-bin/data

2.3 创建myid节点配置文件

节点1

echo 1 > /app/apache-zookeeper-3.8.0-bin/data/myid

节点2

echo 2 > /app/apache-zookeeper-3.8.0-bin/data/myid

节点3

echo 3 > /app/apache-zookeeper-3.8.0-bin/data/myid

等等

2.4 修改配置文件 zoo.cfg 点我下载

cd conf/
mv zoo_sample.cfg zoo.cfg
vim zoo.cfg

调整示例如下:

tickTime=2000
# The number of ticks that the initial 
initLimit=10
# The number of ticks that can pass between 
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/app/apache-zookeeper-3.8.0-bin/data
# the port at which the clients will connect
clientPort=2181
## Metrics Providers
server.1=IP1:2888:3888
server.2=IP2:2888:3888
server.3=IP3:2888:3888
2.4 复制到其他机器

scp -r ./apache-zookeeper-3.8.0-bin/ username@IP2:/app
scp -r ./apache-zookeeper-3.8.0-bin/ username@IP3:/app

Copy完成后,参照 “2.3 创建myid节点配置文件”,调整对应机器的配置文件

2.5 启动Zookeeper

/app/apache-zookeeper-3.8.0-bin/bin/zkServer.sh start

3、环境验证

/app/apache-zookeeper-3.8.0-bin/bin/zkServer.sh status

0

评论区