仅供测试使用

RabbitMQ

镜像地址 https://hub.docker.com/_/rabbitmq/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
docker run -d --hostname rabbit1 --name rabbit1 \
-e RABBITMQ_ERLANG_COOKIE='rabbitcluster' -p 30000:5672 -p 30001:15672 rabbitmq:3-management-alpine
docker run -d --hostname rabbit2 --name rabbit2 --link rabbit1:rabbit1 \
-e RABBITMQ_ERLANG_COOKIE='rabbitcluster' -p 30002:5672 -p 30003:15672 rabbitmq:3-management-alpine
docker run -d --hostname rabbit3 --name rabbit3 --link rabbit1:rabbit1 --link rabbit2:rabbit2 \
-e RABBITMQ_ERLANG_COOKIE='rabbitcluster' -p 30004:5672 -p 30005:15672 rabbitmq:3-management-alpine
docker exec -i -t rabbit2 \bash
rabbitmqctl stop_app
rabbitmqctl join_cluster rabbit@rabbit1
rabbitmqctl start_app
rabbitmqctl set_policy ha-all "^ha\." '{"ha-mode":"all"}'

zk

镜像地址 https://hub.docker.com/_/zookeeper/

1
2
3
4
5
6
7
8
docker run -d -e ZOO_MY_ID=1 -e ZOO_SERVERS='server.1=172.17.0.2:2888:3888 server.2=172.17.0.3:2888:3888 server.3=172.17.0.4:2888:3888' \
--hostname zoo1 zookeeper:3.4
docker run -d -e ZOO_MY_ID=2 -e ZOO_SERVERS='server.1=172.17.0.2:2888:3888 server.2=172.17.0.3:2888:3888 server.3=172.17.0.4:2888:3888' \
--hostname zoo2 zookeeper:3.4
docker run -d -e ZOO_MY_ID=3 -e ZOO_SERVERS='server.1=172.17.0.2:2888:3888 server.2=172.17.0.3:2888:3888 server.3=172.17.0.4:2888:3888' \
--hostname zoo3 zookeeper:3.4

redis

镜像地址 https://hub.docker.com/_/redis/
也可以使用 slaveof的启动命令

1
2
3
4
5
docker run -d --hostname redismaster --name redismaster -p 6379:6379 redis:3.2
docker run -d --hostname redisslave1 --name redisslave1 --link redismaster -p 6380:6379 redis:4.0-alpine
docker run -d --hostname redisslave2 --name redisslave2 --link redismaster -p 6381:6379 redis:4.0-alpine

参考 http://redisdoc.com/