erlang 在Windows服务器上设置RabbitMQ集群

44u64gxh  于 2022-12-08  发布在  Erlang
关注(0)|答案(1)|浏览(205)

我尝试在Windows服务器上建立RabbitMQ集群,这需要使用共享Erlang cookie文件。根据文档,我所需要做的就是确保不同机器上的根目录包含相同的.erlang.cookie文件。所以我所做的就是在两台机器上找到这些文件,并用相同的共享版本覆盖它们。
之后所有rabbitmqctl命令在机器上失败与新的文件版本与“无法连接到节点...”错误信息.我试图重新启动rabbitMQ Windows服务,但rabbitmqctl仍然抱怨.我甚至重新安装了rabbitMQ在那台机器上,但随后.erlang.cookie被重置回旧版本.每当我试图使用新版本的cookie文件,rabbitmqctl失败.当我恢复一个旧版本,它工作得很好。
基本上我被卡住了,在我解决这个问题之前不能继续进行群集设置。任何帮助都将不胜感激。
更新:收到RabbitMQ的回复:rabbitmqctl将从用户主目录中获取cookie,而服务将从C:\windows中获取cookie。因此,您需要将它们彼此同步,以及与另一台机器同步。
这基本上意味着cookie文件需要在两个地方重新调整:C:\Windows和当前用户。

fwzugrvs

fwzugrvs1#

You have the above correct. The service will use the cookie at C:\Windows and when you use rabbitmqctl.bat to query the status it is using the cookie in your user directory ( %USERPROFILE% ).
When the cookies don't match the error look like

C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-2.8.2\sbin>rabbitmqctl.bat status
Status of node 'rabbit@PC-FOOBAR' ...
Error: unable to connect to node 'rabbit@PC-FOOBAR': nodedown

DIAGNOSTICS
===========

nodes in question: ['rabbit@PC-FOOBAR']

hosts, their running nodes and ports:
- PC-FOOBAR: [{rabbit,49186},{rabbitmqctl30566,63150}]

current node details:
- node name: 'rabbitmqctl30566@pc-foobar'
- home dir: U:\
- cookie hash: Vp52cEvPP1PukagWi5S/fQ==

There is one more gotcha for RabbitMQ cookies on Windows... If you have a %HOMEDIR% and %HOMEPATH% environment variables (as we do in our current test environment, and sets homedir above to U:\ ), then RabbitMQ will get the cookie there and if there isn't one it makes one up and writes it there. This left me banging my head on my desk for quite a while when trying to get this working. Once I found this gotcha it was obvious the cookie files were the problem (as documented) they were just at an odd location (not documented AFAIK).
Hope this solves someones pain setting up RabbitMQ Clustering on Windows.

相关问题