我正在尝试学习clustering Rabbitmq节点,并且正在关注this tutorial和the official documentation。
我有2个物理机,它们通过docker部署在Rabbitmq上。 machine1(192.168.1.2)将成为集群,而machine2(192.168.1.3)将成为集群。
当我尝试从machine2运行rabbitmqctl join_cluster [email protected]
时,此操作失败,并显示以下消息。
Clustering node [email protected] with [email protected]
Error: unable to perform an operation on node '[email protected]'. 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 more
* Consult server logs on node [email protected]
* If target node is configured to use long node names, don't forget to use --longnames with CLI tools
DIAGNOSTICS
===========
attempted to contact: ['[email protected]']
[email protected]:
* connected to epmd (port 4369) on 192.168.1.2
* epmd reports node 'rabbit' uses port 25672 for inter-node and CLI tool traffic
* TCP connection succeeded but Erlang distribution failed
* suggestion: check if the Erlang cookie identical for all server nodes and CLI tools
* suggestion: check if all server nodes and CLI tools use consistent hostnames when addressing each other
* suggestion: check if inter-node connections may be configured to use TLS. If so, all nodes and CLI tools must do that
* suggestion: see the CLI, clustering and networking guides on https://rabbitmq.com/documentation.html to learn more
Current node details:
* node name: '[email protected]'
* effective user's home directory: /var/lib/rabbitmq
* Erlang cookie hash: XXXXXXXXXXXXX
在machine1上的错误日志显示与这种连接尝试无关的任何内容。我已经在两个docker容器上验证了cookie的md5sum,它们完全相同。权限也是如此。我假设端口4369不可访问,但是可以访问。
我不确定自己在做什么错。有人可以帮忙吗?
附加信息:
我正在使用rabbitmq:3.85管理图像。它使用Erlang / OTP 23 [erts-11.0.3]。
我一直在检查troubleshooting guide,,但不确定在这里有什么问题。如果可以提供更多信息,请告诉我。
最佳答案
因此,感谢@NeoAnderson和@JoséM,我得以了解发生了什么。
需要通过网络通过服务中Erlang使用的主机名访问运行RMQ的容器。由于无法在另一台计算机上的容器中访问容器的主机名,因此该群集失败。
一个简单的解决方法是编辑容器上的/ etc / hosts文件,以便将IP指向“leader”节点。
我这样做只是为了避免安装RMQ,并不是因为我认为这是最好的方法。或者,docker swarm或k8s将为我提供正确的网络。
但是根本原因肯定是节点名问题。
关于docker - RabbitMQ无法加入集群,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/63212626/