docker搭建rabbitMq集群

1、拉取镜像

docker pull rabbitmq:3.7.17-management
docker tag rabbitmq:3.7.17-management rabbitmq

 2、建立网络

docker network create rabbitmqnet

3、创建容器

docker run -d \
 --name=rabbitmq1 \
 -p 5673:5672 \
 -p 15673:15672 \
 -e RABBITMQ_NODENAME=rabbitmq1 \
 -e RABBITMQ_ERLANG_COOKIE='rabbit_cookie' \
 -h rabbitmq1 \
 --net=rabbitmqnet \
 rabbitmq
docker run -d \
 --name=rabbitmq2 \
 -p 5674:5672 \
 -p 15674:15672 \
 -e RABBITMQ_NODENAME=rabbitmq1 \
 -e RABBITMQ_ERLANG_COOKIE='rabbit_cookie' \
 -h rabbitmq2 \
 --net=rabbitmqnet \
 rabbitmq
docker run -d \
 --name=rabbitmq3 \
 -p 5675:5672 \
 -p 15675:15672 \
 -e RABBITMQ_NODENAME=rabbitmq1 \
 -e RABBITMQ_ERLANG_COOKIE='rabbitmq_cookie' \
 -h rabbitmq3 \
 --net=rabbitmqnet \
 rabbitmq

4、后两个节点

docker exec -it rabbitmq2 /bin/bash
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster --ram rabbitmq1@rabbitmq1
rabbitmqctl start_app
docker exec -it rabbitmq3 /bin/bash
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster --ram rabbitmq1@rabbitmq1
rabbitmqctl start_app

5、运行http://192.168.3.115:15673/

docker搭建rabbitMq集群_第1张图片

你可能感兴趣的:(RabbitMq,docker,rabbitmq,java,spring)