rabbitmq集群搭建报错:[error] Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only

1.背景描述

在创建rabbitmq集群时,需要将当前节点的.erlang.cookie文件数据修改为第一个节点的.erlang.cookie文件内容,这里为了防止手动vim修改导致数据末尾的自动换行符的引入,我使用了文件的直接替换,随后在重启当前的mq节点服务时,报错如下:

[root@net-test-leel ~]# service rabbitmq-server restart
Redirecting to /bin/systemctl restart rabbitmq-server.service
Job for rabbitmq-server.service failed because the control process exited with error code. See "systemctl status rabbitmq-server.service" and "journalctl -xe" for details.

结果就是rabbitmq启动失败

[root@net-test-leel ~ rabbitmq]# service rabbitmq-server status
Redirecting to /bin/systemctl status rabbitmq-server.service
● rabbitmq-server.service - RabbitMQ broker
   Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; disabled; vendor preset: disabled)
   Active: activating (auto-restart) (Result: exit-code) since Wed 2023-02-15 03:14:13 CST; 8s ago
  Process: 32656 ExecStart=/usr/sbin/rabbitmq-server (code=exited, status=1/FAILURE)
 Main PID: 32656 (code=exited, status=1/FAILURE)
   Status: "Standing by"

Feb 15 03:14:13 qyyc01-test-ec2240001236.qyyc01.ksyun.com systemd[1]: Failed to start RabbitMQ broker.
Feb 15 03:14:13 qyyc01-test-ec2240001236.qyyc01.ksyun.com systemd[1]: Unit rabbitmq-server.service entered failed state.
Feb 15 03:14:13 qyyc01-test-ec2240001236.qyyc01.ksyun.com systemd[1]: rabbitmq-server.service failed.

随后,执行reset时报错

[error] Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only

2:问题解决

报错的内容是权限问题,当前这个文件只能文件的所有者才能访问,因为这个文件是从其他节点上复制并替换的,所以需要重新赋予权限,在rabbitmq的默认安装路径/var/lib/rabbitmq/下执行如下命令,

sudo chown rabbitmq:rabbitmq .erlang.cookie        
sudo chmod 400 .erlang.cookie

随后,问题解决,可以正常启动mq了

[root@net-test-leel ~]# service rabbitmq-server restart
Redirecting to /bin/systemctl restart rabbitmq-server.service

你可能感兴趣的:(运维,其他,开发工具,rabbitmq,erlang,分布式)