centos docker搭建rabbitmq集群(单台服务器)

单台服务器做的集群好像没有什么意义,因为服务器一挂,所有的容器都挂了。

不过可以安装来玩玩

1、创建三个节点

#docker run -d --hostname rabbit_host1 --name rabbitmq1 -p 15672:15672 -p 5672:5672 -e RABBITMQ_NODENAME=rabbit -e RABBITMQ_DEFAULT_USER=tech -e RABBITMQ_DEFAULT_PASS=tech -e RABBITMQ_ERLANG_COOKIE='rabbitmq_cookie_tech' --privileged=true -v /root/rabbitmq/1/lib:/var/lib/rabbitmq rabbitmq:management

#docker run -d --hostname rabbit_host2 --name rabbitmq2 -p 15673:15672 -p 5673:5672 --link rabbitmq1:rabbit_host1 -e RABBITMQ_NODENAME=rabbit -e RABBITMQ_DEFAULT_USER=tech -e RABBITMQ_DEFAULT_PASS=tech -e RABBITMQ_ERLANG_COOKIE='rabbitmq_cookie_tech' --privileged=true -v /root/rabbitmq/2/lib:/var/lib/rabbitmq rabbitmq:management

#docker run -d --hostname rabbit_host3 --name rabbitmq3 -p 15674:15672 -p 5674:5672 --link rabbitmq1:rabbit_host1 --link rabbitmq2:rabbit_host2 -e RABBITMQ_NODENAME=rabbit -e RABBITMQ_DEFAULT_USER=tech -e RABBITMQ_DEFAULT_PASS=tech -e RABBITMQ_ERLANG_COOKIE='rabbitmq_cookie_tech' --privileged=true -v /root/rabbitmq/3/lib:/var/lib/rabbitmq rabbitmq:management

 

 2、对节点进行配置

节点1:

#rabbitmqctl stop_app 

#rabbitmqctl reset

#rabbitmqctl start_app

 

 节点2:

#rabbitmqctl stop_app

#rabbitmqctl reset

#rabbitmqctl join_cluster rabbit@rabbit_host1

#rabbitmqctl start_app

 

 

 节点3: 

#rabbitmqctl stop_app

#rabbitmqctl reset

#rabbitmqctl join_cluster rabbit@rabbit_host1

#rabbitmqctl start_app

 

3、启动三个节点的web管理插件

设置账号/密码:admin/admin

#rabbitmqctl add_user admin admin

设置admin权限

#rabbitmqctl set_user_tags admin administrator

#rabbitmq-plugins enable rabbitmq_management

4、浏览器登录

地址:http://192.168.59.103:15672

地址:http://192.168.59.103:15673

地址:http://192.168.59.103:15674

 

posted @ 2022-05-24 16:50  leihongnu  阅读(67)  评论(0编辑  收藏  举报