centos7的rabbitmq升级到3.7.10集群
Posted wangkaiok
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7的rabbitmq升级到3.7.10集群相关的知识,希望对你有一定的参考价值。
centos7的rabbitmq升级到3.7.10集群
#卸载
[root@linux-node1 ~]# systemctl stop rabbitmq-server
[root@linux-node1 ~]# yum remove rabbitmq-server -y
[root@linux-node1 yum.repos.d]# yum remove erlang* -y
[root@linux-node1 ~]# 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包的目录下)
[root@linux-node1 ~]#wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.10/rabbitmq-server-3.7.10-1.el7.noarch.rpm
[root@linux-node1 ~]#yum install -y rabbitmq-server-3.7.10-1.el7.noarch.rpm
[root@linux-node1 ~]# systemctl start rabbitmq-server
[root@linux-node1 ~]# systemctl enable rabbitmq-server
############
[root@linux-node1 yum.repos.d]# rabbitmqctl add_user admin admin
Creating user "admin" ...
[root@linux-node1 yum.repos.d]# rabbitmqctl set_permissions admin ".*" ".*" ".*"
Setting permissions for user "admin" in vhost "/" ...
密码设置成admin
[root@linux-node1 ~]# 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 rabbit@linux-node1... started 6 plugins.
[root@linux-node1 ~]# systemctl restart rabbitmq-server
[root@linux-node1 ~]# 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,并保证权限一直
[root@linux-node1 ~]# scp /var/lib/rabbitmq/.erlang.cookie 192.168.56.12:/var/lib/rabbitmq/
#[root@linux-node1 ~]# scp /var/lib/rabbitmq/.erlang.cookie 192.168.56.13:/var/lib/rabbitmq/
先停止运行节点,然后以后台方式启动 RabbitMQ Server(node1和node2分别执行):
[root@linux-node1 ~]# systemctl stop rabbitmq-server
[root@linux-node1 ~]# rabbitmq-server -detached
Warning: PID file not written; -detached was passed.
[root@linux-node2 ~]# systemctl stop rabbitmq-server
[root@linux-node2 ~]# rabbitmq-server -detached
Warning: PID file not written; -detached was passed.
然后我们以node1作为集群中心,在node2上执行加入集群中心命令(节点类型为磁盘节点):
[root@linux-node2 ~]# rabbitmqctl stop_app
[root@linux-node2 ~]# rabbitmqctl reset
[root@linux-node2 ~]# rabbitmqctl join_cluster rabbit@linux-node1
//默认是磁盘节点,如果是内存节点的话,需要加--ram参数
[root@linux-node2 ~]# rabbitmqctl start_app
查看集群的状态(包含node1和node2节点):
[root@linux-node2 ~]# rabbitmqctl cluster_status
Cluster status of node ‘rabbit@linux-node2‘ ...
[{nodes,[{disc,[‘rabbit@linux-node1‘,‘rabbit@linux-node2‘]}]},
{running_nodes,[‘rabbit@linux-node1‘,‘rabbit@linux-node2‘]},
{cluster_name,<<"rabbit@linux-node2">>},
{partitions,[]}]
#镜像模式
[root@linux-node1 ~]# 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.
以上是关于centos7的rabbitmq升级到3.7.10集群的主要内容,如果未能解决你的问题,请参考以下文章
CentOS7安装RabbitMQ整合Laravel5.8消息队列
CentOS7安装RabbitMQ整合Laravel5.8消息队列
Erlang/OTP 升级丢失现有的 RabbitMQ 消息