CentOS7安装Zookeeper伪集群
准备
1. 服务器上先安装好JDK
安装zookeeper单机版
cd /opt wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz tar -xzhf ./zookeeper-3.4.14.tar.gz cp /zookeeper-3.4.14/zoo_sample.cfg .//zookeeper-3.4.14/zoo.cfg
安装zookeeper集群
cd /opt mkdir zookeeper_cluster cd zookeeper_cluster cp -fr /opt/zookeeper-3.4.14 /opt/zookeeper_cluster/1 cp -fr /opt/zookeeper-3.4.14 /opt/zookeeper_cluster/2 cp -fr /opt/zookeeper-3.4.14 /opt/zookeeper_cluster/3 mkdir -p /opt/zookeeper_cluster/1/data mkdir -p /opt/zookeeper_cluster/1/log sed -i 's/dataDir=.*/dataDir=\/opt\/zookeeper_cluster\/1\/data/g' ./1/conf/zoo.cfg echo 'dataLogDir=/opt/zookeeper_cluster/1/log' >> ./1/conf/zoo.cfg sed -i 's/clientPort=2181/clientPort=2181/g' ./1/conf/zoo.cfg echo 'server.1=192.168.0.180:2881:3881' >> ./1/conf/zoo.cfg echo 'server.2=192.168.0.180:2882:3882' >> ./1/conf/zoo.cfg echo 'server.3=192.168.0.180:2883:3883' >> ./1/conf/zoo.cfg echo '4lw.commands.whitelist=*' >> ./1/conf/zoo.cfg echo '1' > ./1/data/myid mkdir -p /opt/zookeeper_cluster/2/data mkdir -p /opt/zookeeper_cluster/2/log sed -i 's/dataDir=.*/dataDir=\/opt\/zookeeper_cluster\/2\/data/g' ./2/conf/zoo.cfg echo 'dataLogDir=/opt/zookeeper_cluster/2/log' >> ./2/conf/zoo.cfg sed -i 's/clientPort=2181/clientPort=2182/g' ./2/conf/zoo.cfg echo 'server.1=192.168.0.180:2881:3881' >> ./2/conf/zoo.cfg echo 'server.2=192.168.0.180:2882:3882' >> ./2/conf/zoo.cfg echo 'server.3=192.168.0.180:2883:3883' >> ./2/conf/zoo.cfg echo '4lw.commands.whitelist=*' >> ./2/conf/zoo.cfg echo '2' > ./2/data/myid mkdir -p /opt/zookeeper_cluster/3/data mkdir -p /opt/zookeeper_cluster/3/log sed -i 's/dataDir=.*/dataDir=\/opt\/zookeeper_cluster\/3\/data/g' ./3/conf/zoo.cfg echo 'dataLogDir=/opt/zookeeper_cluster/3/log' >> ./3/conf/zoo.cfg sed -i 's/clientPort=2181/clientPort=2183/g' ./3/conf/zoo.cfg echo 'server.1=192.168.0.180:2881:3881' >> ./3/conf/zoo.cfg echo 'server.2=192.168.0.180:2882:3882' >> ./3/conf/zoo.cfg echo 'server.3=192.168.0.180:2883:3883' >> ./3/conf/zoo.cfg echo '4lw.commands.whitelist=*' >> ./3/conf/zoo.cfg echo '3' > ./3/data/myid
启动脚本
#!/bin/bash cd /opt/zookeeper_cluster ./1/bin/zkServer.sh start ./2/bin/zkServer.sh start ./3/bin/zkServer.sh start
关闭脚本
#!/bin/bash cd /opt/zookeeper_cluster ./1/bin/zkServer.sh stop ./2/bin/zkServer.sh stop ./3/bin/zkServer.sh stop
相关推荐
airfish000 2020-06-14
OwenJi 2020-05-08
sushuanglei 2020-11-12
xingyuzhe 2020-09-21
newcome 2020-09-09
XiaoMuFireAnt 2020-09-02
gracecxj 2020-08-25
zyshappy 2020-08-16
我爱熊猫 2020-08-07
luvzhan 2020-07-28
HelloC先生 2020-07-27
wanjichun 2020-07-26
clmngu 2020-07-26
shenxiuwen 2020-07-16
枫叶上的雨露 2020-07-04
yang0cs 2020-06-28
bruce 2020-06-28
middleware0 2020-06-27
luotuo 2020-06-26