[RabbitMQ]Windows环境下rabbitmqclt(Command Line Tools)出现Erlang distribution failed错误的解决方法

摘要

当使用rabbitmqctl时出现Erlang distribution failed,把%SystemRoot%WindowsSystem32configsystemprofile下的.erlang.cookie 复制到%SystemRoot%UsersUsersName后重启RabbitMQ服务

前情概要

今天在使用RabbitMQ突然无法登陆Web Management,用rabbitmqctl的list_user命令查看用户时发现报了如下错误

attempted to contact: ['rabbit@nodeB']
rabbit@nodeB:
* connected to epmd (port 4369) on nodeB
* epmd reports node 'rabbit' running on port 25672
* TCP connection succeeded but Erlang distribution failed
* Authentication failed (rejected by the remote node), please check the Erlang cookie
current node details:
- node name: rabbitmqcli70@NULL
- effective user's home directory: C:Users**
- Erlang cookie hash: *********==

重点在这两行

TCP connection succeeded but Erlang distribution failed
please check the Erlang cookie

因此,重点从erlang cookie下手

解决过程

百度和stackoverflow,无果,基本都是用管理员身份重装RabbitMQ,然而实际问题并不在此。于是直奔官网。

在RabbitMQ官网Command Line Tools下发现erlang Cookie除了Users文件夹下还有另一个存放的地方,对比发现systemprofile里的才是正确的cookie,替换Users下的cookie后重启RabbitMQ ,运行rabbitmqctl,可以正常运行命令了

正常运行list_user发现guest用户被删除了,重新利用rabbitmqctl建立一个管理员用户之后终于可以登录Management了。以防万一,也为了调试方便,在Admin页面重新建立guest用户。

实际上,RabbitMQ nodes与CLT tools利用erlang cookie来辨认它们之间是否能互相连接,若两个erlang cookie不一致则无法使用CLI tools

下面贴出解决方法,有兴趣的可以去最下方的链接,在RabbitMQ官网查看具体说明

解决方法

  1. %SystemRoot%WindowsSystem32configsystemprofile中复制.erlang.cookie
  2. <%SystemRoot%UsersUsersName>中把上一步的.erlang.cookie覆盖此文件夹的.erlang.cookie(以防万一先复制副本)
  3. 重启RabbitMQ服务,这一步应该可以忽略
  4. 重新打开rabbitmqctl,现在可以执行命令了

相关链接:

http://www.rabbitmq.com/cli.html

原文地址:https://www.cnblogs.com/mirageJ/p/9041451.html