Zookeeper伪分布式配置

解压文件

tar -zxvf zookeeper-3.4.10.tar.gz
mv zookeeper-3.4.10 /opt/zookeeper/zookeeper3.4

修改配置文件

cd /opt/zookeeper/zookeeper3.4/

cp conf/zoo_sample.cfg conf/zoo_1.cfg

vi conf/zoo_1.cfg 
dataDir=/opt/zookeeper/zookeeper3.4/data/zk1

clientPort=2181

server.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890
cat conf/zoo_1.cfg > conf/zoo_2.cfg
vi conf/zoo_2.cfg
dataDir=/opt/zookeeper/zookeeper3.4/data/zk2

clientPort=2182

server.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890
cat conf/zoo_1.cfg > conf/zoo_3.cfg
vi conf/zoo_3.cfg
dataDir=/opt/zookeeper/zookeeper3.4/data/zk3

clientPort=2183

server.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890

2019-09-12_20-45-21

mkdir -p data/zk1
mkdir -p data/zk2
mkdir -p data/zk3

# 给每一个zookeeper服务添加唯一标识ID,来标识是哪一个server
echo 1 > data/zk1/myid
echo 2 > data/zk2/myid
echo 3 > data/zk3/myid

启动zookeeper

# 使用配置文件来启动三个zookeeper服务
./bin/zkServer.sh start conf/zoo_1.cfg 
./bin/zkServer.sh start conf/zoo_2.cfg
./bin/zkServer.sh start conf/zoo_3.cfg 

2019-09-12_20-55-52

# 查看三个zookeeper的状态
./bin/zkServer.sh status conf/zoo_1.cfg
./bin/zkServer.sh status conf/zoo_2.cfg
./bin/zkServer.sh status conf/zoo_3.cfg 

2019-09-12_20-57-03

# 关闭服务
./bin/zkServer.sh stop conf/zoo_1.cfg 

2019-09-12_21-00-08

# 启动zookeeper的客户端
./bin/zkCli.sh -server localhost:2182

2019-09-12_21-03-00

posted @ 2019-09-13 19:28  会走的树  阅读(642)  评论(0编辑  收藏  举报