1.安装zookeeper
进入/export/software目录,将zookeeper软件包导入该目录下。解压zookeeper软件包 到/export/servers目录下,并重命名为zookeeper。
[root@master ~]# cd /export/software/
[root@master software]# rz -be
[root@master software]# ls
apache-hive-3.1.2-bin.tar.gz hbase-2.2.3-bin.tar.gz
apache-zookeeper-3.5.7-bin.tar.gz jdk-8u212-linux-x64.tar.gz
hadoop-3.1.3.tar.gz
[root@master software]# tar -zxvf apache-zookeeper-3.5.7-bin.tar.gz -C /export/servers/
[root@master software]# cd /export/servers/
[root@master servers]# mv apache-zookeeper-3.5.7-bin zookeeper
2.文件配置
(1)在/export/servers/zookeeper这个目录下创建zkData,并配置myid文件
[root@master servers]# cd /export/servers/zookeeper
[root@master zookeeper]# mkdir zkData
[root@master zookeeper]# cd zkData
[root@master zkData]# vi myid
在文件增加如下内容:
1
(2) 将zookeeper/conf下的zoo_sample.cfg文件修改为zoo.cfg,并配置zoo.cfg文件
[root@master zkData]# cd ../conf
[root@master conf]# mv zoo_sample.cfg zoo.cfg
[root@master conf]# vi zoo.cfg
修改数据存储路径配置
dataDir=/export/servers/zookeeper/zkData
并在文件末尾增加如下内容:
server.1=master:2888:3888
server.2=slave1:2888:3888
server.3=slave2:2888:3888
(3)将zookeeper安装目录写入环境变量,打开文件/etc/profice,在文件末尾添加以下内容,并刷 新。
export ZOOKEEPER_HOME=/export/servers/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin
[root@master conf]# vi /etc/profile
[root@master conf]# source /etc/profile
slave1和slave2主机也可以加入环境变量。
3. 分发文件
在集群上分发配置好的zookeeper文件夹
[root@master conf]# cd /export/servers/
[root@master servers]# scp -r /export/servers/zookeeper slave1:/export/servers/
[root@master servers]# scp -r /export/servers/zookeeper slave2:/export/servers/
修改slave1和slave2节点上zkData文件夹下的myid文件内容,分别改为2和3。
4.启动Zookeeper和查看状态
分别启动
[root@master zookeeper]# bin/zkServer.sh start
[root@slave1 zookeeper]# bin/zkServer.sh start
[root@slave2 zookeeper]# bin/zkServer.sh start
查看状态
[root@master zookeeper]# bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Mode: follower
[root@master zookeeper]#
[root@salve1 zookeeper]# bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Mode: leader
[root@salve1 zookeeper]#
[root@slave2 zookeeper]# bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /export/servers/zookeeper/bin/../conf/zoo.cfg
Mode: follower
[root@slave2 zookeeper]#
版权归原作者 EsmeZhao 所有, 如有侵权,请联系我们删除。