irpas技术客

关于搭建rabbitmq集群报错Error: unable to perform an operation on node ‘rabbit@localhost‘

大大的周 3935

项目场景:

搭建rabbitmq集群时mq1为主,mq2,mq3为从 mq2和mq3加入集群时输入命令:rabbitmqctl join_cluster rabbit@mq1报错

问题描述:

具体报错为: Error: unable to perform an operation on node ‘rabbit@localhost’. Please see diagnostics information and suggestions below.

Most common reasons for this are:

Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)CLI tool fails to authenticate with the server (e.g. due to CLI tool’s Erlang cookie not matching that of the server)Target node is not running

In addition to the diagnostics info below:

See the CLI, clustering and networking guides on https://rabbitmq.com/documentation.html to learn moreConsult server logs on node rabbit@localhostIf target node is configured to use long node names, don’t forget to use --longnames with CLI tools

DIAGNOSTICS

attempted to contact: [rabbit@localhost]

rabbit@localhost:

connected to epmd (port 4369) on localhostepmd reports: node ‘rabbit’ not running at all no other nodes on localhostsuggestion: start the node

Current node details:

node name: ‘rabbitmqcli-1268-rabbit@localhost’effective user’s home directory: /var/lib/rabbitmqErlang cookie hash: Y808sbgvYL/c08FQp16K+w== 原因分析:

我找了一天都没有找到任何的解决办法,网上其他的都是在本地把mq跑起来的,而我是在虚拟机上跑起来的,这时候我观察到错误中写的是 Error: unable to perform an operation on node ‘rabbit@localhost’. Please see diagnostics information and suggestions below.

它上面写的是rabbit@localhost而不是rabbit@mq2或者rabbit@mq3

我就怀疑可能是hostname和hosts这一层关系没有对应上

结果我修改了hostname和rabbitmq-env.conf之后就可以加入集群了!

解决方案: 1.先把hostname和hosts文件的映射对应上

我们先查看hosts文件里面的内容(如果没有添加ip映射则需要自己手动添加) 我们这时就用mq3为例,修改mq3虚拟机上的hostname

hostnamectl set-hostname mq3

这时我们把mq跑起来

service rabbitmq-server start

再把mq关闭

rabbitmqctl stop_app

就会有提示

Stopping rabbit application on node rabbit@mq3

这时的提示已经显示rabbit@mq3说明修改成功

此时尝试一下加入集群,如果成功加入则不需要以下步骤

2. 修改rabbitmq变量(如果这时已经可以加入集群则不用此步骤) vim /etc/rabbitmq/rabbitmq-env.conf

将NODENAME=rabbit@localhost改成 NODENAME=rabbit@mq3

此时我们在尝试加入把mq3加入mq1集群

rabbitmqctl join_cluster rabbit@mq1

这时就可以成功加入集群了 加入集群后启动rabbitmq

rabbitmqctl start_app

这时我们去页面查看一下

搭建rabbitmq集群成功!


1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,会注明原创字样,如未注明都非原创,如有侵权请联系删除!;3.作者投稿可能会经我们编辑修改或补充;4.本站不提供任何储存功能只提供收集或者投稿人的网盘链接。

标签: #Unable #To #perform #an #operation #on #node