zookeeper集群搭建步骤
Posted xingxin666
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zookeeper集群搭建步骤相关的知识,希望对你有一定的参考价值。
前提:准备3台linux虚机
下面是实操命令步骤
一、下载zk
[app@zknode01 ~]$ mkdir zookeeper
[app@zknode01 ~]$ cd zookeeper
[app@zknode01 zookeeper]$ mkdir zkdata
[app@zknode01 zookeeper]$ mkdir zkdatalog
[app@zknode01 zookeeper]$ wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz
二、解压zk
[app@zknode01 zookeeper]$ tar -xzvf zookeeper-3.4.13.tar.gz
[app@zknode01 zookeeper]$ cd zookeeper-3.4.13/
[app@zknode01 zookeeper-3.4.13]$ cd conf
[app@zknode01 conf]$ cp zoo_sample.cfg zoo.cfg
三、配置zoo.cfg
[app@zknode01 conf]$ vim zoo.cfg
dataDir=/home/app/zookeeper/zkdata
dataLogDir=/home/app/zookeeper/zkdatalog
server.1=10.10.30.238:12888:13888
server.2=10.10.30.239:12888:13888
server.3=10.10.30.240:12888:13888
以上ip需配置实际地址
node2和node3重复以上步骤
四、配置myid
[app@zknode01 ~]$ echo "1" > /home/app/zookeeper/zkdata/myid
[app@zknode02 ~]$ echo "2" > /home/app/zookeeper/zkdata/myid
[app@zknode03 ~]$ echo "3" > /home/app/zookeeper/zkdata/myid
五、编辑zookeeper.out输出路径
在zkEnv.sh
修改ZOO_LOG_DIR="$ZOOKEEPER_PREFIX/logs"
六、启动zk
启动node01
[app@zknode01 ~]$ /home/app/zookeeper/zookeeper-3.4.13/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/app/zookeeper/zookeeper-3.4.13/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[app@zknode01 ~]$
启动node02
[app@zknode02 conf]$ /home/app/zookeeper/zookeeper-3.4.13/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/app/zookeeper/zookeeper-3.4.13/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
启动node03
[app@zknode03 conf]$ /home/app/zookeeper/zookeeper-3.4.13/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/app/zookeeper/zookeeper-3.4.13/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
查看node1状态
[app@zknode01 ~]$ /home/app/zookeeper/zookeeper-3.4.13/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/app/zookeeper/zookeeper-3.4.13/bin/../conf/zoo.cfg
Mode: follower
[app@zknode01 ~]$
查看node2状态
[app@zknode02 conf]$ /home/app/zookeeper/zookeeper-3.4.13/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/app/zookeeper/zookeeper-3.4.13/bin/../conf/zoo.cfg
Mode: leader
[app@zknode02 conf]$
查看node3状态
[app@zknode03 conf]$ /home/app/zookeeper/zookeeper-3.4.13/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/app/zookeeper/zookeeper-3.4.13/bin/../conf/zoo.cfg
Mode: follower
[app@zknode03 conf]$
zk集群搭建完毕。
以上是关于zookeeper集群搭建步骤的主要内容,如果未能解决你的问题,请参考以下文章
Zookeeper -- Zookeeper 集群搭建 集群角色说明