简体   繁体   中英

RabbitMQ, Erlang: How to "make sure the erlang cookies are the same"

I am using RabbitMQ with Grails, and a problem cropped up this morning. When I run rabbitmqctl status it tells me:

C:\Users\BuildnTest2>rabbitmqctl status
Status of node 'rabbit@BUILDNTEST2-PC' ...
Error: unable to connect to node 'rabbit@BUILDNTEST2-PC': nodedown diagnostics:
- nodes and their ports on BUILDNTEST2-PC: [{rabbit,49164},
                                        {rabbitmqctl27693,49286}]
- current node: 'rabbitmqctl27693@BuildnTest2-PC'
- current node home dir: C:\Users\BuildnTest2
- current node cookie hash: cSYB8tsT4mGGZHSUGQi08w==

When I go to the Rabbit troubleshooting page they say:

then you should make sure the Erlang cookies are the same.

What does this mean and how is it accomplished?

Googling found this forum thread which claims to have instructions to solving this problem, but alas it just redirects back to the rabbit site where there is no answer.

In my case, for some reason the cookie ( .erlang.cookie ) stored under C:\\Windows\\ was different from the one I had stored under my home ( %HOMEDRIVE% %HOMEPATH% , which was C:\\ for me).

Once I copied the cookie from C:\\Windows into my my home folder everything started working.

For what it's worth, in 2018, the docs are WRONG. In windows 10, the default location of the cookie file appears to be:

C:\Windows\System32\config\systemprofile

and NOT

C:\Windows

as the docs say.

The best thing to do is to look at the log file, which is typically located in your user %AppData%\\Roaming\\RabbitMQ\\log directory.

The log file contains this entry, which helped me determine the cookie location:

node           : rabbit@computername
home dir       : C:\WINDOWS\system32\config\systemprofile

For those out there googling, this same erlang cookie error can happen when you are missing the HOME parameter from your environment configuration. For example, on the default ArchLinux installation of rabbitmq.

In this case, the service is started with systemctl start rabbitmq and it generates a cookie but the cli tools like rabbitmqctl status will not work out of the box because they do not know the home location.

default /etc/rabbitmq/rabbitmq-env.conf

NODENAME=rabbit
NODE_IP_ADDRESS=0.0.0.0
NODE_PORT=5672

LOG_BASE=/var/log/rabbitmq
MNESIA_BASE=/var/lib/rabbitmq/mnesia

modified /etc/rabbitmq/rabbitmq-env.conf

NODENAME=rabbit
NODE_IP_ADDRESS=127.0.0.1
NODE_PORT=5672

HOME=/var/lib/rabbitmq
LOG_BASE=/var/log/rabbitmq
MNESIA_BASE=/var/lib/rabbitmq/mnesia

ref https://bbs.archlinux.org/viewtopic.php?id=191587

The definitive answer to your specific question, on the RabbitMQ site is at http://www.rabbitmq.com/clustering.html

However, from your status dump, it doesn't look as though this is your issue. It just looks as though your node is down. Am I correct in assuming that you aren't running a cluster? The fact that the node that you can't connect to is the same as the one you are running the commands from indicates this.

If the RabbitMQ service is running then run rabbitmqctl start If it isn't running then go to services and start it and then the above. The erlang cookie is irrelevant for non-clustered configurations.

In home directory of the user running erlang process, there is hidden file .erlang.cookie. It holds string which is responsible for the topology of erlang cluster. Make sure that the string (cookie) is the same across all nodes you want to connect. If there is no cookie, create one.

Synchronise Erlang Cookies (when running a manually installed Windows Service) Erlang Security Cookies used by the service account and the user running rabbitmqctl.bat must be synchronised for rabbitmqctl.bat to function. To ensure Erlang cookie files contain the same string, copy the .erlang.cookie file from the Windows directory (normally C:\\WINDOWS.erlang.cookie) to replace the user .erlang.cookie. The user cookie will be in the user's home directory (%HOMEDRIVE%%HOMEPATH%), eg C:\\Documents and Settings\\%USERNAME%.erlang.cookie or C:\\Users\\%USERNAME%.erlang.cookie (Windows Vista and later).

https://www.rabbitmq.com/install-windows-manual.html

我将 cookie 从C:\\Windows复制到我的主文件夹( C:\\Users\\Current User\\.erlang.cookie ),一切都开始正常工作。

Make sure the rabbitmq erlang.cookie matches the erlang.cookie in your user directory:

The rabbitmq erlang cookie...

...will be typically located in /var/lib/rabbitmq/.erlang.cookie on Unix systems and C:\\Users\\Current User.erlang.cookie or C:\\Documents and Settings\\Current User.erlang.cookie on Windows systems. ( http://www.rabbitmq.com/clustering.html#setup )

Make sure that matches with ~/.erlang.cookie.

If you run the MacPorts version of rabbitmq-server on OSX, you need to check the ~rabbitmq/.erlang.cookie file. It must match the one in /opt/local/var/lib/rabbitmq/.erlang.cookie, otherwise "rabbitmqctl" is not able to connect.

I was trying to cluster and even when the cookies matched it wouldn't work for me... the only thing that finally worked was setting the ERLANG_HOME variable in my environment variables.

After I set this, I was able to copy the cookie from my master broker to the one I wanted to cluster with and the join worked fine.

"Set ERLANG_HOME to where you actually put your Erlang installation, eg C:\\Program Files\\erlx.xx (full path). The RabbitMQ batch files expect to execute %ERLANG_HOME%\\bin\\erl.exe.

Go to Start > Settings > Control Panel > System > Advanced > Environment Variables. Create the system environment variable ERLANG_HOME and set it to the full path of the directory which contains bin\\erl.exe. "

https://www.rabbitmq.com/install-windows-manual.html

I observed this issue when clone server made alive with name change. Problem solved after clean rabbitmq and erlang installation.

The proper way to change the original to custom erlang.cookie in LINUX, not sure about the other OS platforms.

pkill beam
pkill epmd
echo 'CUSTOMCOOKIE' > /var/lib/rabbitmq/.erlang.cookie
pkill beam
pkill epmd

wait for a few seconds like 30-60sec then start the app

rabbitmqctl start_app

Maybe the first attempt got failed then try a few more times it will work. If not then you messed up with something else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM