这里用了三台主机,系统为CentOS7
1、修改hosts
#vim /etc/hosts
172.50.0.31 node1
172.50.0.34 node2
172.50.0.37 node3
2、安装JAVA环境
#yum install -y java
3、下载程序包
#wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/stable/zookeeper-3.4.9.tar.gz
4、解压到指定目录
#tar xvf zookeeper-3.4.9.tar.gz -C /usr/local/
#cd /usr/local
#ln -sv zookeeper-3.4.9 zookeeper
#cd zookeeper
#cd conf
#cp zoo_sample.cfg zoo.cfg
5、修改各节点配置文件
#vim zoo.cfg
dataDir=/data/zookeeper
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 node2:/usr/local/zookeeper/conf
#scp zoo.cfg node3:/usr/local/zookeeper/conf
6、在各节点创建数据目录
#mkdir /data/zookeeper
7、在各节点创建myid文件,并指定配置文件中对应的id编号
#echo 1 /var/lib/zookeeper/myid
#echo 2 /var/lib/zookeeper/myid
#echo 3 /var/lib/zookeeper/myid
8、分别启动各节点服务
#./zkServer.sh start
#netstat -tnlp
9、查看节点角色
#./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Mode: leader