RabbitMQ集群过程中遇到的一些问题的解决办法

时间:2020-12-29 15:28:04
    环境:
容器环境:docker 1.12.1
镜像版本:centos 7.2.1151
1.添加集群节点报错:
[root@rabbitmqsalver2 /]# rabbitmqctl join_cluster --ram rabbit@rabbitmqmaster
Clustering node rabbit@rabbitmqsalver2 with rabbit@rabbitmqmaster ...
Error: unable to connect to nodes [rabbit@rabbitmqmaster]: nodedown

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

attempted to contact: [rabbit@rabbitmqmaster]

rabbit@rabbitmqmaster:
* connected to epmd (port 4369) on rabbitmqmaster
* epmd reports node 'rabbit' running on port 25672
* TCP connection succeeded but Erlang distribution failed

* Authentication failed (rejected by the remote node), please check the Erlang cookie


current node details:
- node name: 'rabbitmq-cli-88@rabbitmqsalver2'
- home dir: /root
- cookie hash: 55WeQTsiv71JcEDq/JcE9Q==
     从错误提示 TCP connection succeeded but Erlang distribution failed,Authentication failed (rejected by the remote node), please check the Erlang cookie 可以看出是 Erlang cookie的问题,节点的cookie和主节点的cookie不一致。解决办法在每个主机的$HOME目录下新建一个.erlang.cookie,里面随便输入一段字符串。或者在/var/lib/rabbitmq这个目录下新建同样的文件,里面随便写些字符,但是要在/etc/rabbitmq/rabbit-env.conf里面通过HOME=/var/lib/rabbitmq来指定。所有节点的.erlang.cookie必须保持一致。
2.启动RabbitMQ出现"Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only",这个是cookie访问权限的问题,解决办法如下:
[root@rabbitmqmaster /]# chmod 600 /var/lib/rabbitmq/.erlang.cookie