一、环境介绍

磁盘节点: 192.168.142.129 rabbit129

内存节点: 192.168.142.130 rabbit130

内存节点: 192.168.142.131 rabbit131

rabbitmq官网:http://www.rabbitmq.com

官网不能下载老版本包,这里使用网盘的包进行测试:https://pan.baidu.com/share/init?surl=bG_nP0iCdAejkctFp1QztQ&pwd=4mlw

安装包:erlang-23.3.4.11-1.el7.x86_64.rpm   rabbitmq-server-3.9.16-1.el7.noarch.rpm

二、集群部署

1.主机环境配置

systemctl stop firewalld
systemctl disable firewalld
sed -i 's/enforcing/disabled/' /etc/selinux/config
setenforce 0
----------------#配置每个主机的主机名以及主机名hosts解析---------------
vim /etc/hosts
192.168.142.129 rabbit129
192.168.142.130 rabbit130
192.168.142.131 rabbit131

hostnamectl set-hostname rabbit129
reboot

2.启动服务

rpm -ivh erlang-23.3.4.11-1.el7.x86_64.rpm
yum install socat -y
rpm -ivh rabbitmq-server-3.9.16-1.el7.noarch.rpm
systemctl start rabbitmq-server
systemctl stop rabbitmq-server
scp -r /var/lib/rabbitmq/.erlang.cookie 192.168.142.130:/var/lib/rabbitmq/
scp -r /var/lib/rabbitmq/.erlang.cookie 192.168.142.131:/var/lib/rabbitmq/
rabbitmq-server -detached             #三个节点都启动服务
rabbitmq-plugins enable rabbitmq_management     #三个节点启动web控制台插件
rabbitmqctl status                    #查看rabbitmq状态
rabbitmqctl cluster_status            #查看集群状态

3.节点加入集群

#rabbit130、rabbit131节点执行
rabbitmqctl stop_app                       #停掉应用
rabbitmqctl reset                         #重置
abbitmqctl join_cluster --ram rabbit@rabbit129
rabbitmqctl start_app

centos7.9搭建默认rabbitmq集群模式_rabbitmq

4.添加用户并设置权限

rabbitmqctl list_users                                   #列出用户
rabbitmqctl add_user admin 123456                        #添加用户
rabbitmqctl list_permissions                             #列出用户权限
rabbitmqctl set_permissions admin ".*" ".*" ".*"         #设置权限
rabbitmqctl set_user_tags admin administrator            #设置角色

centos7.9搭建默认rabbitmq集群模式_rabbitmq_02

三、浏览器访问

访问地址IP:15672     账号密码:admin/123456

centos7.9搭建默认rabbitmq集群模式_rabbitmq_03