docker-compose部署Rabbitmq集群

DevOps admin 2个月前 (07-27) 85次浏览 0个评论

部署节点一

vim docker-compose.yml

version: ‘3’
services:
rabbit1:
image: rabbitmq:3.3.8.5-management
container_name: rabbit1
hostname: rabbit1
ports:
– 4369:4369
– 5672:5672
– 15672:15672
– 15674:15674
– 25672:25672
– 35197:35197
volumes:
– /data/rabbitmq:/var/lib/rabbitmq
– /etc/localtime:/etc/localtime
environment:
– RABBITMQ_DEFAULT_USER=admin
– RABBITMQ_DEFAULT_PASS=123456
– RABBITMQ_ERLANG_COOKIE=’SECERLANGCOOKIE’

extra_hosts:
– “rabbit2:192.168.1.162”                # 不能加入自己,否则会一直重启
– “rabbit3:192.168.1.166”

 

部署节点二

version: ‘3’
services:
rabbit2:
image: rabbitmq:3.3.8.5-management
container_name: rabbit2
hostname: rabbit2
ports:
– 4369:4369
– 5672:5672
– 15672:15672
– 15674:15674
– 25672:25672
– 35197:35197
volumes:
– /data/rabbitmq:/var/lib/rabbitmq
– /etc/localtime:/etc/localtime
environment:
– RABBITMQ_ERLANG_COOKIE=’SECERLANGCOOKIE’
– RABBITMQ_DEFAULT_VHOST=/
– RABBITMQ_LOGS=/var/lib/rabbitmq/rabbitmq.log

extra_hosts:
– “rabbit1:192.168.1.160”
– “rabbit3:192.168.1.166”

 

部署节点三

version: ‘3’
services:
rabbit3:
image: rabbitmq:3.3.8.5-management
container_name: rabbit3
hostname: rabbit3
ports:
– 4369:4369
– 5672:5672
– 15672:15672
– 15674:15674
– 25672:25672
– 35197:35197
volumes:
– /data/rabbitmq:/var/lib/rabbitmq
– /etc/localtime:/etc/localtime
environment:
– RABBITMQ_ERLANG_COOKIE=’SECERLANGCOOKIE’
– RABBITMQ_DEFAULT_VHOST=/
– RABBITMQ_LOGS=/var/lib/rabbitmq/rabbitmq.log

extra_hosts:
– “rabbit1:192.168.1.160”
– “rabbit2:192.168.1.162”

 

把节点二和节点三加入到集群中

docker exec -it rabbit2 bash

rabbitmqctl stop_app

rabbitmqctl join_cluster [email protected]

rabbitmqctl start_app

 

查看集群

 


转载请注明原文链接:docker-compose部署Rabbitmq集群
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址