CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 102db57ef270 zookeeper "/docker-entrypoint.s"24 minutes ago Up 24 minutes 2888/tcp, 3888/tcp, 0.0.0.0:2182->2181/tcp compose_zoo2_1 cca20ce3dd60 zookeeper "/docker-entrypoint.s"24 minutes ago Up 24 minutes 2888/tcp, 3888/tcp, 0.0.0.0:2183->2181/tcp compose_zoo3_1 767bc1cc85cc zookeeper "/docker-entrypoint.s"24 minutes ago Up 24 minutes 2888/tcp, 0.0.0.0:2181->2181/tcp, 3888/tcp compose_zoo1_1
查是leader还是follower
进入其中一个,看是leader还是follower
1
docker exec -it compose_zoo1_1 /bin/bash
进入bash中后,输入./bin/zkServer.sh status 会出现下面状态
1 2 3 4
bash-4.3# ./bin/zkServer.sh status ZooKeeper JMX enabled by default Using config: /conf/zoo.cfg Mode: follower
创建结点
docker exec -it compose_zoo1_1 /bin/bash 进入容器后
1
./bin/zkCli.sh -server 127.0.0.1:2181
进入zookeeper中
1 2 3 4 5 6 7
[zk: 127.0.0.1:2181(CONNECTED) 0] ls / [zookeeper] [zk: 127.0.0.1:2181(CONNECTED) 1] create /test mytest Created /test [zk: 127.0.0.1:2181(CONNECTED) 2] ls / [zookeeper, test]