Docker安装rabbitmq集群

创建网卡

docker network create rabbitmq_network

安装三个rabbitmq组件,一主两从

docker run -d --name=rabbitmq_master -p 5672:5672 -p 15672:15672 -e RABBITMQ_NODENAME=rabbitmq_master -e RABBITMQ_ERLANG_COOKIE='rabbitmq' -h rabbitmq_master --net=rabbitmq_net -v /data/rabbitmq/master:/var/lib/rabbitmq -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=rabbitmq_test rabbitmq:3.10.7-management
docker run -d --name=rabbitmq_slave1 -p 5673:5672 -p 15673:15672 -e RABBITMQ_NODENAME=rabbitmq_slave1 -e RABBITMQ_ERLANG_COOKIE='rabbitmq' -h rabbitmq_slave1 --net=rabbitmq_net -v /data/rabbitmq-1/slave1/:/var/lib/rabbitmq -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=rabbitmq_test rabbitmq:3.10.7-management
docker run -d --name=rabbitmq_slave2 -p 5674:5672 -p 15674:15672 -e RABBITMQ_NODENAME=rabbitmq_slave2 -e RABBITMQ_ERLANG_COOKIE='rabbitmq' -h rabbitmq_slave2 --net=rabbitmq_net -v /data/rabbitmq/slave2/:/var/lib/rabbitmq -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=rabbitmq_test rabbitmq:3.10.7-management

开启三个组件的管理端插件

docker exec -it rabbitmq_master rabbitmq-plugins enable rabbitmq_management
docker exec -it rabbitmq_slave1 rabbitmq-plugins enable rabbitmq_management
docker exec -it rabbitmq_slave2 rabbitmq-plugins enable rabbitmq_management

salve1加入集群

docker exec -it rabbitmq_slave1 rabbitmqctl stop_app
docker exec -it rabbitmq_slave1 rabbitmqctl join_cluster rabbitmq_master@rabbitmq_master
docker exec -it rabbitmq_slave1 rabbitmqctl start_app

salve2加入集群

docker exec -it rabbitmq_slave2 rabbitmqctl stop_app
docker exec -it rabbitmq_slave2 rabbitmqctl join_cluster rabbitmq_master@rabbitmq_master
docker exec -it rabbitmq_slave2 rabbitmqctl start_app

开启镜像队列

docker exec -it rabbitmq_slave1 rabbitmqctl set_policy ha-all "^" '{"ha-mode":"all"}'

You May Also Like

More From Author

+ There are no comments

Add yours