wjy0 2019-06-20
docker搭建系列
docker环境搭建zk集群
docker搭建redis集群
docker环境搭建elasticsearch
docker搭建rabbitmq集群
docker环境搭建ELK
对于个人开发者而言,学习分布式的好多东东,都比较费劲,因为手头的机器不够。若是单机使用虚拟机来启动一个个虚拟server话,又比较耗费资源,要求单机性能够好。幸好docker这种轻量级的东东出现了。本文主要是记录使用docker搭建zk集群的过程。
这次使用garland搭好的镜像。
docker pull garland/zookeeper
docker run -d \ --name=zk1 \ --net=host \ -e SERVER_ID=1 \ -e ADDITIONAL_ZOOKEEPER_1=server.1=localhost:2888:3888 \ -e ADDITIONAL_ZOOKEEPER_2=server.2=localhost:2889:3889 \ -e ADDITIONAL_ZOOKEEPER_3=server.3=localhost:2890:3890 \ -e ADDITIONAL_ZOOKEEPER_4=clientPort=2181 \ garland/zookeeper docker run -d \ --name=zk2 \ --net=host \ -e SERVER_ID=2 \ -e ADDITIONAL_ZOOKEEPER_1=server.1=localhost:2888:3888 \ -e ADDITIONAL_ZOOKEEPER_2=server.2=localhost:2889:3889 \ -e ADDITIONAL_ZOOKEEPER_3=server.3=localhost:2890:3890 \ -e ADDITIONAL_ZOOKEEPER_4=clientPort=2182 \ garland/zookeeper docker run -d \ --name=zk3 \ --net=host \ -e SERVER_ID=3 \ -e ADDITIONAL_ZOOKEEPER_1=server.1=localhost:2888:3888 \ -e ADDITIONAL_ZOOKEEPER_2=server.2=localhost:2889:3889 \ -e ADDITIONAL_ZOOKEEPER_3=server.3=localhost:2890:3890 \ -e ADDITIONAL_ZOOKEEPER_4=clientPort=2183 \ garland/zookeeper
follower
)root@xixicat:~# echo stat | nc 127.0.0.1 2181 Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT Clients: /127.0.0.1:55531[0](queued=0,recved=1,sent=0) Latency min/avg/max: 0/1/31 Received: 63 Sent: 62 Connections: 1 Outstanding: 0 Zxid: 0x100000005 Mode: follower Node count: 5
leader
)root@xixicat:~# echo stat | nc 127.0.0.1 2182 Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT Clients: /127.0.0.1:53244[0](queued=0,recved=1,sent=0) Latency min/avg/max: 0/0/0 Received: 1 Sent: 0 Connections: 1 Outstanding: 0 Zxid: 0x100000005 Mode: leader Node count: 5
follower
)root@xixicat:~# echo stat | nc 127.0.0.1 2183 Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT Clients: /127.0.0.1:33983[0](queued=0,recved=1,sent=0) Latency min/avg/max: 0/0/0 Received: 1 Sent: 0 Connections: 1 Outstanding: 0 Zxid: 0x100000005 Mode: follower Node count: 5
之前折腾了好几次,国内访问docker.io的网速还是不行,于是就使用了daocloud加速,前提是你得装docker-machine。试用了下,速度提升了不少。