zookeeper集群搭建

zookeeper集群搭建

摘要: zookeeper集群搭建

准备环境

服务器1:192.168.241.101 paascloud-zk-01 端口:2181、2881、3881
服务器2:192.168.241.102 paascloud-zk-02 端口:2182、2882、3882
服务器3:192.168.241.103 paascloud-zk-03 端口:2183、2883、3883
jdk version jdk8.144
zk version 3.4.11

1.安装

1
2
3
4
5
wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.11/
tar -zxvf zookeeper-3.4.11.tar.gz /usr/local/tar -zxvf zookeeper-3.4.11.tar.gz /usr/local
mv zookeeper-3.4.11 zk
mkdir /usr/local/zk/data
mkdir /usr/local/zk/logs

配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
mkdir /usr/local/zk/data
mkdir /usr/local/zk/logs
mv /usr/local/zk/conf/zoo_sample.cfg zoo.cfg
vi zoo.cfg
dataDir=/usr/local/zk/data
dataLogDir=/usr/local/zk/logs
server.1=paascloud-zk-01:2881:3881
server.2=paascloud-zk-02:2882:3882
server.3=paascloud-zk-03:2883:3883
autopurge.snapRetainCount=3
touch /usr/local/zk/data/myid
三台服务顺序 按顺序 一次写入1 2 3
echo 1 > /var/data/zk/myid
echo 1 > /var/data/zk/myid
echo 1 > /var/data/zk/myid

启动服务

1
/usr/local/zk/bin/zkServer.sh start

查看三台服务器的状态

1
/usr/local/zk/bin/zkServer.sh status

服务器1

1
2
3
ZooKeeper JMX enabled by default
Using config: /usr/local/zk/bin/../conf/zoo.cfg
Mode: follower

服务器2

1
2
3
ZooKeeper JMX enabled by default
Using config: /usr/local/zk/bin/../conf/zoo.cfg
Mode: leader

服务器3

1
2
3
ZooKeeper JMX enabled by default
Using config: /usr/local/zk/bin/../conf/zoo.cfg
Mode: follower

到此集群搭建成功
下一节部署taokeeper来监控zk集群状态

评论

:D 一言句子获取中...

加载中,最新评论有1分钟缓存...