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
---------------------------------------------------------------------------------------------
---中间的先忽略,参考:
https://developer.aliyun.com/article/538861
查看集群的状态(包含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.
参考:https://blog.csdn.net/u010833154/article/details/128483642
CentOS 7下修改rabbitmq打开文件数量方法
移除节点:
在主上:
rabbitmqctl -n rabbit@rabbitmq_1 forget_cluster_node rabbit@rabbitmq_2
清除镜像参考:
·
作者:wangkaiok —— 小菜鸟111
出处:http://www.cnblogs.com/wangkaiok/
本文版权归作者和博客园共有,但未经作者同意禁止转载,转载必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。