Linux系统 Docker RabbitMQ容器集群部署
rabbitmq容器集群部署
步骤一:安装配置docker服务下载rabbit服务
# yum -y install git docker 安装git docker 服务
# systemctl start docker 启动docker服务
# systemctl enable docker docker服务开机自动开启
# docker search rabbitmq:management 搜索rabbitmq容器镜像
# docker pull rabbitmq:3.6.15-management
# docker run -d --hostname rabbit1 --name rabbit1 -p 15672:15672 -p 5672:5672 --restart always -v /opt/data/rabbitmq/:/var/lib/rabbitmq -e RABBITMQ_ERLANG_COOKIE='rabbitcookie' rabbitmq:3.6.15-management
# docker run -d --hostname rabbit2 --name rabbit2 --link rabbit1:rabbit1 -p 5673:5672 --restart always -v /opt/data/rabbitmq/:/var/lib/rabbitmq -e RABBITMQ_ERLANG_COOKIE='rabbitcookie' rabbitmq:3.6.15-management
# docker run -d --hostname rabbit3 --name rabbit3 --link rabbit1:rabbit1 --link rabbit2:rabbit2 -p 5674:5672 --restart always -v /opt/data/rabbitmq/:/var/lib/rabbitmq -e RABBITMQ_ERLANG_COOKIE='rabbitcookie' rabbitmq:3.6.15-management
步骤二:加入RabbitMQ节点到集群
设置节点1:
docker exec -it rabbit1 bash
rabbitmqctl add_user admin admin
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
rabbitmq-plugins enable rabbitmq_management
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app
exit
设置节点2,加入到集群:
docker exec -it rabbit2 bash
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster --ram rabbit@rabbit1
rabbitmqctl start_app
exit
参数“--ram”表示设置为内存节点,忽略次参数默认为磁盘节点。
设置节点3,加入到集群:
docker exec -it rabbit3 bash
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster --ram rabbit@rabbit1
rabbitmqctl start_app
exit