RabbitMQ集群I3

2022-05-04 21:31:34 浏览数 (1)

同步 Erlang cookie

集群中node必须使用相同的cookie才能相互通讯

在Linux中cookie的位置一般在 /var/lib/rabbitmq/.erlang.cookie

代码语言:javascript复制
[root@h101 ~]# scp  /var/lib/rabbitmq/.erlang.cookie  root@h102:/var/lib/rabbitmq/.erlang.cookie
The authenticity of host 'h102 (192.168.100.102)' can't be established.
RSA key fingerprint is 78:c4:6f:3f:08:43:d1:2a:02:bf:ec:f3:9f:e3:89:76.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'h102,192.168.100.102' (RSA) to the list of known hosts.
root@h102's password: 
.erlang.cookie                                                                                      100%   20     0.0KB/s   00:00    
[root@h101 ~]# 

Erlang nodes use a cookie to determine whether they are allowed to communicate with each other - for two nodes to be able to communicate they must have the same cookie. The cookie is just a string of alphanumeric characters. It can be as long or short as you like. Every cluster node must have the same cookie. The cookie is also used for tools such as rabbitmqctl and rabbitmq-plugins. Erlang will automatically create a random cookie file when the RabbitMQ server starts up. The easiest way to proceed is to allow one node to create the file, and then copy it to all the other nodes in the cluster. On Unix systems, the cookie will be typically located in /var/lib/rabbitmq/.erlang.cookie or $HOME/.erlang.cookie.

0 人点赞