本篇博客将主要介绍如何进行Zookeeper的分布式安装部署
在Carlota1、Carlota2、Carlota3三台机器上进行部署。
1、解压安装
apache-zookeeper-3.6.1-bin.tar.gz
到三台机器上tar -zxvf apache-zookeeper-3.6.1-bin.tar.gz
mv apache-zookeeper-3.6.1 zookepper3.6.1
2、配置服务器编号
mkdir zkData
cd zkData/
touch myid
3、配置zoo.cfg文件
dataDir=/usr/local/apps/zookeeper-3.6.1/zkData
#添加内容(在对应的机器上把本地机器写为0.0.0.0),以Carlota1为例
#配置中server.后的数字是服务器编号;
#=右边的分别是服务器地址 Follower与集群中的Leader服务器交换信息的端口以及备用端口
server.1=0.0.0.0:2888:3888
server.2=Carlota2:2888:3888
server.3=Carlota3:2888:3888
4、配置环境变量
vi /etc/profile
添加以下内容#Zookeeper
export ZOOKEEPER_HOME=/usr/local/apps/zookeeper-3.6.1
export PATH=$PATH:$ZOOKEEPER_HOME/bin
5、集群启动验证是否成功
zkServer.sh start
来启动zookeeperbin/zkServer.sh status
来查看状态[root@carlota1 zookeeper-3.6.1]# zkServer.sh status ZooKeeper JMX enabled by default Using config: /usr/local/apps/zookeeper-3.6.1/bin/…/conf/zoo.cfg Client port found: 2181. Client address: localhost. Mode: leader
[root@carlota2 zookeeper-3.6.1]# zkServer.sh status ZooKeeper JMX enabled by default Using config: /usr/local/apps/zookeeper-3.6.1/bin/…/conf/zoo.cfg Client port found: 2181. Client address: localhost. Mode: follower