RabbitMQ集群安装


rpm -Uvh *.rpm --nodeps --force
安装依赖(一步步来) rpm
-ivh erlang-22.2.1-1.el7.x86_64.rpm rpm -ivh socat-1.7.3.2-2.el7.x86_64.rpm --nodeps --force rpm -ivh rabbitmq-server-3.8.3-1.el7.noarch.rpm 启动RabbitMQ systemctl start rabbitmq-server systemctl restart rabbitmq-server systemctl status rabbitmq-server
设置RabbitMQ开机自启动 systemctl enable rabbitmq
-server #开启网页插件 rabbitmq-plugins enable rabbitmq_management # 添加用户 rabbitmqctl add_user cnmc cnmc20230630 # 设置用户角色,分配操作权限 rabbitmqctl set_user_tags cnmc administrator # 为用户添加资源权限(授予访问虚拟机根节点的所有权限) rabbitmqctl set_permissions -p "/" cnmc ".*" ".*" ".*"

保证每个服务器上erlang.cookie内容一致 chmod 777 /var/lib/rabbitmq/.erlang.cookie CRAZQSVYQHZKJJFORKFE chmod 400 /var/lib/rabbitmq/.erlang.cookie vim /var/lib/rabbitmq/.erlang.cookie SFUCRTJHNHNTVELYZLDC
注意修改本地节点名称
vim /etc/rabbitmq/rabbitmq-env.conf
export RABBITMQ_NODENAME=rabbit@rabbitmq3
注意防火墙开启4369和25672端口访问权限
firewall-cmd --add-rich-rule="rule family="ipv4" source address="127.0.0.1" port protocol="tcp" port="4369" accept" --permanent
firewall-cmd --add-rich-rule="rule family="ipv4" source address="127.0.0.1" port protocol="tcp" port="25672" accept" --permanent
firewall-cmd --reload


修改hosts
vim /etc/hosts
10.2.1.199 rabbit-node1
10.2.1.200 rabbit-node2
10.2.1.201 rabbit-node3

设置服务器hostname
hostnamectl set-hostname rabbit-node1

# 在rabbit2 节点执行命令 停止并且链接到rabbit1节点
#停止节点
rabbitmqctl stop_app 
# 清空节点状态
rabbitmqctl reset 
# rabbit2和rabbit1构成集群,rabbit2必须能通过rabbit1的主机名ping通
rabbitmqctl join_cluster rabbit@ecs-5167-0615539
# 开启rabbitmq服务
rabbitmqctl start_app

固定服务名 rabbitmq
-env.conf echo 'NODENAME=rabbit@ecs-c775-0615708' >> /etc/rabbitmq/rabbitmq-env.conf

firewall-cmd --zone=public --add-port=5672/tcp --permanent
firewall-cmd --zone=public --add-port=15672/tcp --permanent

卸载erlang
yum remove erlang-erts-R16B-03.18.el7.x86_64

 

posted @ 2023-07-14 15:02  涂山有雨  阅读(22)  评论(0编辑  收藏  举报