部署 zookeeper 集群

这里用了三台主机,系统为CentOS7

节点列表

172.50.0.31
172.50.0.34
172.50.0.37

1、安装JDK

yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel

2、下载程序包

wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/stable/zookeeper-3.4.9.tar.gz

3、解压到指定目录

tar xvf zookeeper-3.4.9.tar.gz -C /usr/local/
cd /usr/local
mv zookeeper-3.4.9 zookeeper
cd zookeeper
cd conf
cp zoo_sample.cfg zoo.cfg

4、修改各节点配置文件

vim zoo.cfg
dataDir=/usr/local/zookeeper/data
dataLogDir=/usr/local/zookeeper/datalog
server.1=172.50.0.31:2888:3888
server.2=172.50.0.34:2888:3888
server.3=172.50.0.37:2888:3888

scp zoo.cfg 172.50.0.34:/usr/local/zookeeper/conf	
scp zoo.cfg 172.50.0.37:/usr/local/zookeeper/conf

5、在各节点创建数据目录和日志目录

mkdir /usr/local/zookeeper/{data,datalog}

6、在各节点创建myid文件,并指定配置文件中对应的id编号

echo 1 > /usr/local/zookeeper/data/myid 	
echo 2 > /usr/local/zookeeper/data/myid	
echo 3 > /usr/local/zookeeper/data/myid

7、分别启动各节点服务

./zkServer.sh start
netstat -tnlp | grep 2181

8、查看节点状态

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

参考:

posted @ 2017-03-09 21:15  KeithTt  阅读(707)  评论(0编辑  收藏  举报