centos7的rabbitmq升级到3.7.10集群
#卸载
[[email protected] ~]# systemctl stop rabbitmq-server
[[email protected] ~]# yum remove rabbitmq-server -y
[[email protected] yum.repos.d]# yum remove erlang* -y
[[email protected] ~]# rm -rf /var/lib/rabbitmq/
1 安装erlang
curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash
yum install erlang -y
查看版本:
erl
3.安装rabbitmq(当前目录为rabbitmq-server-3.7.10-1.el7.noarch.rpm包的目录下)
[[email protected] ~]#wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.10/rabbitmq-server-3.7.10-1.el7.noarch.rpm
[[email protected] ~]#yum install -y rabbitmq-server-3.7.10-1.el7.noarch.rpm
[[email protected] ~]# systemctl start rabbitmq-server
[[email protected] ~]# systemctl enable rabbitmq-server
############
[[email protected] yum.repos.d]# rabbitmqctl add_user admin admin
Creating user "admin" ...
[[email protected] yum.repos.d]# rabbitmqctl set_permissions admin ".*" ".*" ".*"
Setting permissions for user "admin" in vhost "/" ...
密码设置成admin
[[email protected] ~]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
mochiweb
webmachine
rabbitmq_web_dispatch
amqp_client
rabbitmq_management_agent
rabbitmq_management
Applying plugin configuration to [email protected] started 6 plugins.
[[email protected] ~]# systemctl restart rabbitmq-server
[[email protected] ~]# netstat -lntup|grep 5672
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 15851/beam
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 15851/beam
tcp6 0 0 :::5672 :::* LISTEN 15851/beam
无法登录页面,参考:
https://blog.csdn.net/shenhonglei1234/article/details/82745601
vim /usr/lib/rabbitmq/lib/rabbitmq_server-3.7.10/ebin/rabbit.app
将:{loopback_users, [<<”guest”>>]},
改为:{loopback_users, []},
原因:rabbitmq从3.3.0开始禁止使用guest/guest权限通过除localhost外的访问
====登录页面修改密码,重置角色,略
将node1上的.erlang.cookie传输到node2、node3,并保证权限一直
[[email protected] ~]# scp /var/lib/rabbitmq/.erlang.cookie 192.168.56.12:/var/lib/rabbitmq/
#[[email protected] ~]# scp /var/lib/rabbitmq/.erlang.cookie 192.168.56.13:/var/lib/rabbitmq/
先停止运行节点,然后以后台方式启动 RabbitMQ Server(node1和node2分别执行):
[[email protected] ~]# systemctl stop rabbitmq-server
[[email protected] ~]# rabbitmq-server -detached
Warning: PID file not written; -detached was passed.
[[email protected] ~]# systemctl stop rabbitmq-server
[[email protected] ~]# rabbitmq-server -detached
Warning: PID file not written; -detached was passed.
然后我们以node1作为集群中心,在node2上执行加入集群中心命令(节点类型为磁盘节点):
[[email protected] ~]# rabbitmqctl stop_app
[[email protected] ~]# rabbitmqctl reset
[[email protected] ~]# rabbitmqctl join_cluster [email protected]
//默认是磁盘节点,如果是内存节点的话,需要加--ram参数
[[email protected] ~]# rabbitmqctl start_app
查看集群的状态(包含node1和node2节点):
[[email protected] ~]# rabbitmqctl cluster_status
Cluster status of node ‘[email protected]‘ ...
[{nodes,[{disc,[‘[email protected]‘,‘[email protected]‘]}]},
{running_nodes,[‘[email protected]‘,‘[email protected]‘]},
{cluster_name,<<"[email protected]">>},
{partitions,[]}]
#镜像模式
[[email protected] ~]# rabbitmqctl set_policy ha-all "^" ‘{"ha-mode":"all","ha-sync-mode":"automatic"}‘
Setting policy "ha-all" for pattern "^" to "{\"ha-mode\":\"all\",\"ha-sync-mode\":\"automatic\"}" with priority "0" ...
...done.
原文地址:https://www.cnblogs.com/wangkaiok/p/11942855.html