369、集群-RabbitMQ-镜像集群搭建
docker run -d --hostname rabbitmq01 --name rabbitmq01 -v /mydata/rabbitmq/rabbitmq01:/var/lib/rabbitmq -p 15672:15672 -p 5672:5672 -e RABBITMQ_ERLANG_COOKIE='dalianpai' rabbitmq:management [root@cicd ~]# docker run -d --hostname rabbitmq02 --name rabbitmq02 -v /mydata/rabbitmq/rabbitmq02:/var/lib/rabbitmq -p 15674:15672 -p 5674:5672 -e RABBITMQ_ERLANG_COOKIE='dalianpai' --link rabbitmq01:rabbitmq01 rabbitmq:management ae25c092e6f5cadd37f8ac6b4ed76aaab04a43605aaf3d739d8e053148b8cf4c You have mail in /var/spool/mail/root [root@cicd mail]# docker run -d --hostname rabbitmq03 --name rabbitmq03 -v /mydata/rabbitmq/rabbitmq03:/var/lib/rabbitmq -p 15675:15672 -p 5675:5672 -e RABBITMQ_ERLANG_COOKIE='dalianpai' --link rabbitmq01:rabbitmq01 --link rabbitmq02:rabbitmq02 rabbitmq:management 2ca59e853b3908f0e368bf7f3ce8368b6e180993169b6ab388d5056a8a5535a0 [root@cicd mail]# docker ps -a [root@cicd mail]# docker exec -it rabbitmq01 /bin/bash root@rabbitmq01:/# rabbitmqctl stop_app Stopping rabbit application on node rabbit@rabbitmq01 ... root@rabbitmq01:/# rabbitmqctl reset Resetting node rabbit@rabbitmq01 ... root@rabbitmq01:/# rabbitmqctl start_app Starting node rabbit@rabbitmq01 ... root@rabbitmq01:/# [root@cicd mail]# docker exec -it rabbitmq02 /bin/bash root@rabbitmq02:/# rabbitmqctl stop_app Stopping rabbit application on node rabbit@rabbitmq02 ... root@rabbitmq02:/# rabbitmqctl reset Resetting node rabbit@rabbitmq02 ... root@rabbitmq02:/# rabbitmqctl join_cluster --ram rabbit@rabbitmq01 Clustering node rabbit@rabbitmq02 with rabbit@rabbitmq01 root@rabbitmq02:/# rabbitmqctl start_app Starting node rabbit@rabbitmq02 ... root@rabbitmq02:/# exit exit [root@cicd mail]# docker exec -it rabbitmq03 /bin/bash root@rabbitmq03:/# rabbitmqctl stop_app Stopping rabbit application on node rabbit@rabbitmq03 ... root@rabbitmq03:/# rabbitmqctl reset Resetting node rabbit@rabbitmq03 ... root@rabbitmq03:/# rabbitmqctl join_cluster --ram rabbit@rabbitmq01 Clustering node rabbit@rabbitmq03 with rabbit@rabbitmq01 root@rabbitmq03:/# rabbitmqctl start_app Starting node rabbit@rabbitmq03 ... root@rabbitmq03:/# exit exit [root@cicd mail]# [root@cicd mail]# docker exec -it rabbitmq01 /bin/bash root@rabbitmq01:/# rabbitmqctl set_policy -p / ha "^" '{"ha-mode":"all","ha-sync-mode":"automatic"}' Setting policy "ha" for pattern "^" to "{"ha-mode":"all","ha-sync-mode":"automatic"}" with priority "0" for vhost "/" ... root@rabbitmq01:/# rabbitmqctl list_policies -p / Listing policies for vhost "/" ... vhost name pattern apply-to definition priority / ha ^ all {"ha-mode":"all","ha-sync-mode":"automatic"}