我在笔记本电脑上安装了 RabbitMQ。我启动服务器 ( rabbitmq-server -detached
) 然后rabbitmqctl start_app
,一切正常(我的 Java 应用程序可以连接和发送/接收消息)。
$ rabbitmqctl start_app
Starting node 'rabbit@11-020-7206' ...
但是当我去另一个网络不同的地方时,笔记本电脑会得到另一个主机名,我不能再用它做任何事情了。如果我尝试停止或启动它,我会收到节点已关闭的错误。
$ rabbitmqctl stop
Stopping and halting node 'rabbit@Mahdis-MacBook-Pro' ...
Error: unable to connect to node 'rabbit@Mahdis-MacBook-Pro': nodedown
DIAGNOSTICS
===========
attempted to contact: ['rabbit@Mahdis-MacBook-Pro']
rabbit@Mahdis-MacBook-Pro:
* connected to epmd (port 4369) on Mahdis-MacBook-Pro
* epmd reports node 'rabbit' running on port 25672
* TCP connection succeeded but Erlang distribution failed
* suggestion: hostname mismatch?
* suggestion: is the cookie set correctly?
* suggestion: is the Erlang distribution using TLS?
current node details:
- node name: 'rabbitmq-cli-14528@Mahdis-MacBook-Pro'
- home dir: /Users/mahdi
- cookie hash: HBqyY/jYPLAyrH1wt3dTWQ==
如果我尝试完全启动服务器,它会说节点正在运行:
$ rabbitmq-server -detached
Warning: PID file not written; -detached was passed.
ERROR: node with name "rabbit" already running on "Mahdis-MacBook-Pro"
如何修复主机名以避免这种混淆?