docker:部署zookeeper叢集
阿新 • • 發佈:2019-01-11
下載映象
docker pull zookeeper
zk叢集的搭建 docker-compose.yml指令碼
version: '2' services: zoo1: image: docker.io/zookeeper restart: always container_name: zoo1 ports: - "2182:2181" environment: ZOO_MY_ID: 1 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 zoo2: image: docker.io/zookeeper restart: always container_name: zoo2 ports: - "2183:2181" environment: ZOO_MY_ID: 2 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 zoo3: image: docker.io/zookeeper restart: always container_name: zoo3 ports: - "2184:2181" environment: ZOO_MY_ID: 3 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
啟動與檢視
COMPOSE_PROJECT_NAME=zk_test docker-compose up -d
COMPOSE_PROJECT_NAME=zk_test docker-compose ps
連線 ZK 叢集
1、使用 Docker 命令列客戶端連線 ZK 叢集 docker run -it --rm \ --link zoo1:zk1 \ --link zoo2:zk2 \ --link zoo3:zk3 \ --net zktest_default \ zookeeper zkCli.sh -server zk1:2181,zk2:2181,zk3:2181 2、通過本地主機連線 ZK 叢集 bin路徑下: zkCli.sh -server localhost:2182,localhost:2183,localhost:2184
檢視叢集
1、yum -y install nc 下載nc命令
2、echo stat | nc 127.0.0.1 2182
echo stat | nc 127.0.0.1 2183
echo stat | nc 127.0.0.1 2184