前提准备3台centos7.0虚拟机
node6:192.168.101.129
node7:192.168.101.137
node8:192.168.101.138
并在三台虚拟机上配置hosts为
192.168.101.129 node6
192.168.101.137 node7
192.168.101.138 node8
进入node6 解压zookeeper.tar.gz到 /opt/soft/zookeeper-3.4.10下
tar -zxvf zookeeper-3.4.10.tar.gz -C /opt/soft
cd /opt/soft/zookeeper-3.4.10/
mkdir data
mkdir logs
cp conf/zoo_sample.cfg conf/zoo.cfg
vi conf/zoo.cfg
修改以下部分:
dataDir=/opt/soft/zookeeper-3.4.10/data
dataLogDir=/opt/soft/zookeeper-3.4.10/logs
server.1=node6:2888:3888
server.2=node7:2888:3888
server.3=node8:2888:3888
保存退出。
vi data/myid
输入1并保存。
cd ..
在node7,node8中建文件夹/opt/soft
scp -r zookeeper-3.4.10 root@node7:/opt/soft/zookeeper-3.4.10
scp -r zookeeper-3.4.10 root@node7:/opt/soft/zookeeper-3.4.10
vi /opt/soft/zookeeper-3.4.10/data/myid
分别改数字1为2,3
分别关闭三台服务器的防火墙,然后启动服务。
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
bin/zkServer.sh start
bin/zkServer.sh status
注:java.net.NoRouteToHostException: No route to host
则大多因为防火墙没关,关闭即可:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
bin/zkServer.sh status 显示正常说明启动成功。