[Linux]RabbitMQ - 解决Error: unable to connect to node rabbit@localhost: nodedown

Posted 千千寰宇

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Linux]RabbitMQ - 解决Error: unable to connect to node rabbit@localhost: nodedown相关的知识,希望对你有一定的参考价值。

1 问题

环境: CentOS7.8.2003 (x86 / 64bit)
版本: RabbitMQ 3.6.15 (Erlang 19.3)
安装方式: 二进制源码压缩安装

2 解决思路

2.1 思路1 关闭进程,并重启

step1 查询mq的进程

ps -ef | grep rabbitmq

step2 杀掉mq进程

ps -ef | grep rabbitmq | grep -v grep | awk \'{print $2}\' | xargs kill -9

step3 启动mq

rabbitmq-server -detached

Warning: PID file not written; -detached was passed.

step4 在查询mq的状态

rabbitmqctl status

2.2 思路2 erlang安装版本与rabbitmq版本不兼容

查询erlang与rabbitmq的版本兼容性地址: https://www.rabbitmq.com/which-erlang.html

2.3 思路3 RabbitMQ的依赖件: erlang的cookie

1 安装方式:
Linux中,rabbitmq安装方式主要有两种:RPM安装 和 二进制安装(编译安装/压缩包安装)
2 .erlang.cookie是什么?
.erlang.cookie是erlang实现分布式的必要文件;
erlang分布式的每一个节点上要保持相同的.erlang.cookie文件,同时该文件的权限至少应为400。
3 .erlang.cookie文件路径?

  • Linux
    • $HOME/.erlang.cookie 【二进制安装(编译安装/压缩包安装)】
      • 若用root角色安装,则 /root/.erlang.cookie;其他用户为/home/用户名/.erlang.cookie
      • ~/.erlang.cookie
    • /var/lib/rabbitmq/.erlang.cookie 【RPM安装】
  • Windows
    • C:\\Users${username}.erlang
    • 用上面这个文件覆盖下面目录的文件
      • C:\\Windows.erlang.cookie
      • C:\\Windows\\System64\\config\\systemprofile
      • C:\\Windows\\System32\\config\\systemprofile

4 可通过rabbitmq的启动日志,查看rabbitmq的home目录以及.erlang.cookie文件的位置等信息。

=INFO REPORT==== 20-Jul-2018::13:34:56 ===
node           : rabbit@he10
home dir       : /root (我是用root用户启动的)
config file(s) : /home/rabbitmq_server-3.6.1/etc/rabbitmq/rabbitmq.config (not found)
cookie hash    : 063Gh+RyPjHRzyuSPf9wWA==

...
rabbit@localhost:
  * connected to epmd (port 4369) on localhost
  * epmd reports: node \'rabbit\' not running at all
                  other nodes on localhost: [\'rabbitmq-cli-17\']
  * suggestion: start the node
current node details:
- node name: \'rabbitmq-cli-17@Hydrant\'
- home dir: /root
- cookie hash: 063Gh+RyPjHRzyuSPf9wWA==

2.4 思路4 重新安装RabbitMQ的服务

代价最高

3 补充

RabbitMQ相关的命令

[rabbitmq-server]
[service] rabbitmq-server stop #[service] : 表示中括号内的service命令可加可不加,下同
[service] rabbitmq-server start #前台启动rabbitmq服务
[service] rabbitmq-server restart
[service] rabbitmq-service remove
[service] rabbitmq-server -detached #后台启动rabbitmq服务

[rabbitmqctl]
rabbitmqctl status
rabbitmqctl stop
    Stops the Erlang node on which RabbitMQ is running. To restart the node follow the instructions for Running the Server in the installation guide[1].
rabbitmqctl start_app
rabbitmqctl stop_app
rabbitmqctl shutdown
    Shuts down the Erlang process on which RabbitMQ is running. The command is blocking and will return after the Erlang process exits. If RabbitMQ fails to stop, it will return a non-zero exit code.
rabbitmqctl change_password {username} {password}
rabbitmqctl list_users #查看监听用户
rabbitmqctl add_user {username} {password}
rabbitmqctl set_user_tags {username} {tag ...}
    rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions [-p vhost] {user} {conf} {write} {read}
    rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
rabbitmqctl delete_user {username}

[rabbitmq-plugins]
rabbitmq-plugins enable/disable rabbitmq_management #开启/禁用 rabbitmq的web管理插件
rabbitmq-plugins enable/disable rabbitmq_web_stomp
rabbitmq-plugins enable/disable rabbitmq_tracing #开启/禁用 rabbitmq_tracing能跟踪RabbitMQ中消息的流入流出情况

4 参考文献

以上是关于[Linux]RabbitMQ - 解决Error: unable to connect to node rabbit@localhost: nodedown的主要内容,如果未能解决你的问题,请参考以下文章

linux下安装rabbitmq报错

rabbit.bat server启动闪退,rabbitmq (ArgumentError) argument error,rabbitmq页面无法开启解决方案

RabbitMQ 安装及启动报错 Error description: noproc 解决办法

rabbitmq {ssl_upgrade_error, timeout} 报错解决方法

RabbitMQ 启动报错 ERROR: epmd error for host xxx: timeout (timed out)

RabbitMQ教程-在Linux上安装RabbitMQ报错解决方案