搭建rabbitmq的docker集群

环境:

三个rabbitmq节点,加一个haproxy做前端

确保三台服务器都可以按主机名找到对方(/etc/hosts或dns)


node1,node2,node3分别执行:

docker run -d --net host --name rabbitmq -e RABBITMQ_ERLANG_COOKIE='IEWIRJDIS8WJDUU2WSW' $REGISTRY_IP:5000/library/rabbitmq


node2:

docker exec rabbitmq rabbitmqctl stop_app

docker exec rabbitmq rabbitmqctl join_cluster rabbit@node1

docker exec rabbitmq rabbitmqctl start_app


node3:

docker exec rabbitmq rabbitmqctl stop_app

docker exec rabbitmq rabbitmqctl join_cluster rabbit@node2

docker exec rabbitmq rabbitmqctl start_app


较验:
node1,node2,node3分别执行:
docker exec rabbitmq rabbitmqctl cluster_status

你可能感兴趣的:(docker)