快速docker搭建Rabbit MQ集群

快速docker搭建Rabbit MQ集群

1、新增一个network ,在这个network 里面创建集群:

docker network create rabbitmq-net

2、分别创建三个容器

docker run -d --hostname rabbit1 --name myrabbit1 -p 15672:15672 -p 5672:5672 -e RABBITMQ_ERLANG_COOKIE='rabbitcookie' --net rabbitmq-net rabbitmq:3.9-management

docker run -d --hostname rabbit2 --name myrabbit2 -p 15673:15672 -p 5673:5672  -e RABBITMQ_ERLANG_COOKIE='rabbitcookie' --net rabbitmq-net rabbitmq:3.9-management

docker run -d --hostname rabbit3 --name myrabbit3 -p 15674:15672 -p 5674:5672 -e RABBITMQ_ERLANG_COOKIE='rabbitcookie' --net rabbitmq-net rabbitmq:3.9-management

3、配置myrabbit1

docker exec -it myrabbit1 bash
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app
exit

4、配置myrabbit2

docker exec -it myrabbit2 bash
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster --ram rabbit@rabbit1
rabbitmqctl start_app
exit

5、配置myrabbit3

docker exec -it myrabbit3 bash
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster --ram rabbit@rabbit1
rabbitmqctl start_app
exit

注意几个点:
1、必须创建NetWork;
2、RABBITMQ_ERLANG_COOKIE得值必须一致;

你可能感兴趣的:(docker,docker,容器,运维,rabbitmq)