docker部署rabbitmq集群
时间: 2023-04-29 17:00:45 浏览: 224
Docker 部署 RabbitMQ 集群的步骤如下:
1. 创建一个 Docker 网络
```
docker network create rabbitmq-cluster
```
2. 启动三个 RabbitMQ 节点
```
docker run -d --hostname rabbit1 --name rabbit1 --network rabbitmq-cluster rabbitmq:3-management
docker run -d --hostname rabbit2 --name rabbit2 --network rabbitmq-cluster rabbitmq:3-management
docker run -d --hostname rabbit3 --name rabbit3 --network rabbitmq-cluster rabbitmq:3-management
```
3. 设置 RabbitMQ 集群
```
docker exec -it rabbit2 rabbitmqctl stop_app
docker exec -it rabbit2 rabbitmqctl reset
docker exec -it rabbit2 rabbitmqctl join_cluster rabbit@rabbit1
docker exec -it rabbit2 rabbitmqctl start_app
docker exec -it rabbit3 rabbitmqctl stop_app
docker exec -it rabbit3 rabbitmqctl reset
docker exec -it rabbit3 rabbitmqctl join_cluster rabbit@rabbit1
docker exec -it rabbit3 rabbitmqctl start_app
```
4. 验证 RabbitMQ 集群是否正常工作
```
docker exec -it rabbit1 rabbitmqctl cluster_status
```
以上就是 Docker 部署 RabbitMQ 集群的步骤。
阅读全文