方案:
实施:
#在第一台节点上面安装zookeeper:
tar xzvf zookeeper-3.4.8.tar.gz -C /usr/local/
cd /usr/local/
ln -sv zookeeper-3.4.8 zookeeper
cd /usr/local/zookeeper
mkdir -p data3
mkdir -p logs3
cd /usr/local/zookeeper/conf
cp -r zoo_sample.cfg zoo.cfg
vim zoo.cfg
tickTime=2000
initLimit=5
syncLimit=2
dataDir=/usr/local/zookeeper/data3
dataLogDir=/usr/local/zookeeper/logs3
clientPort=2181
server.189=192.168.1.189:2888:3888
server.190=192.168.1.190:2888:3888
server.191=192.168.1.191:2888:3888
echo "189" >> /usr/local/zookeeper/data3/myid
#将服务器的标识内容登记到/usr/local/zookeeper/data3/myid文件中,这个189是我的服务器的IP地址最后一位。
/usr/local/zookeeper/bin/zkServer.sh start
#启动服务
/usr/local/zookeeper/bin/zkServer.sh stop
#停止服务
/usr/local/zookeeper/bin/zkServer.sh status
#查看主从角色,leader是主角色,follower是从角色