docker搭建系列git
docker環境搭建zk集羣github
docker搭建redis集羣redis
docker環境搭建elasticsearchdocker
docker搭建rabbitmq集羣shell
docker環境搭建ELKsegmentfault
對於我的開發者而言,學習分佈式的好多東東,都比較費勁,由於手頭的機器不夠。如果單機使用虛擬機來啓動一個個虛擬server話,又比較耗費資源,要求單機性可以好。幸虧docker這種輕量級的東東出現了。本文主要是記錄使用docker搭建zk集羣的過程。網絡
此次使用garland搭好的鏡像。elasticsearch
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。試用了下,速度提高了很多。
分佈式