Linux 单机搭建Zookeeper集群

下载

http://archive.apache.org/dist/zookeeper

解压缩

tar -zxvf /opt/zookeeper-3.4.9.tar.gz -C /home/

复制

cp -a /home/zookeeper-3.4.9 zookeeper-1
cp -a /home/zookeeper-3.4.9 zookeeper-2
cp -a /home/zookeeper-3.4.9 zookeeper-3

创建目录

mkdir /home/zookeeper-1/data
mkdir /home/zookeeper-2/data
mkdir /home/zookeeper-3/data

mkdir /home/zookeeper-1/data_log
mkdir /home/zookeeper-2/data_log
mkdir /home/zookeeper-3/data_log

echo "1" > /home/zookeeper-1/data/myid
echo "2" > /home/zookeeper-2/data/myid
echo "3" > /home/zookeeper-3/data/myid

配置文件

cp -a /home/zookeeper-1/conf/zoo_sample.cfg zoo.cfg
cp -a /home/zookeeper-2/conf/zoo_sample.cfg zoo.cfg
cp -a /home/zookeeper-3/conf/zoo_sample.cfg zoo.cfg

vim /home/zookeeper-1/conf/zoo.cfg 

dataDir=/home/zookeeper-1/data
dataLogDir=/home/zookeeper-1/data_log
clientPort=2171 server.
1=127.0.0.1:2888:3888 server.2=127.0.0.1:2889:3889 server.3=127.0.0.1:2890:3890 vim /home/zookeeper-3/conf/zoo.cfg dataDir=/home/zookeeper-2/data dataLogDir=/home/zookeeper-2/data_log
clientPort=2181 server.
1=127.0.0.1:2888:3888 server.2=127.0.0.1:2889:3889 server.3=127.0.0.1:2890:3890 vim /home/zookeeper-1/conf/zoo.cfg dataDir=/home/zookeeper-3/data dataLogDir=/home/zookeeper-3/data_log
clientPort=2191 server.
1=127.0.0.1:2888:3888 server.2=127.0.0.1:2889:3889 server.3=127.0.0.1:2890:3890

启动

/home/zookeeper-1/bin/zkServer.sh start
/home/zookeeper-2/bin/zkServer.sh start
/home/zookeeper-3/bin/zkServer.sh start

/home/zookeeper-1/bin/zkServer.sh status
/home/zookeeper-2/bin/zkServer.sh status
/home/zookeeper-3/bin/zkServer.sh status

 

转载于:https://www.cnblogs.com/BINGJJFLY/p/11310721.html

你可能感兴趣的:(Linux 单机搭建Zookeeper集群)