搭建Zookeeper-3.4.13分布式集群

1.简介

zookeeper:分布式协调应用程序 官方网站:http://zookeeper.apache.org

最新版本:3.4.13 下载地址:zookeeper-3.4.13

2.安装部署

1vim /etc/hosts
2192.168.33.14 node4
3192.168.33.15 node5
4192.168.33.16 node6

3.下载安装

先安装jdk

1yum -y install java

下载zookeeper

1yum -y install wget
2wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz
3tar xf zookeeper-3.4.13.tar.gz 
4mv zookeeper-3.4.13 /usr/local/zookeeper

4.配置

1mv /usr/local/zookeeper/conf/zoo{_sample,}.cfg
2cat >> /usr/local/zookeeper/conf/zoo.cfg<<EOF
3server.1 = node4:2888:3888
4server.2 = node5:2888:3888
5server.3 = node6:2888:3888
6EOF

node4:

1echo 1 > /tmp/zookeeper/myid

node5:

1echo 2 > /tmp/zookeeper/myid

node6:

1echo 3 > /tmp/zookeeper/myid

5.启动集群

1cd /usr/local/zookeeper/bin && ./zkServer.sh start

6.查看集群节点状态

查看下面的信息说明集群配置正常,如果不正常,查看日志文件/usr/local/zookeeper/bin/zookeeper.out

1./zkServer.sh status
2ZooKeeper JMX enabled by default
3Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
4Mode: leader