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/下执行如下命令,文章来源:https://www.toymoban.com/news/detail-553719.html
sudo chown rabbitmq:rabbitmq .erlang.cookie
sudo chmod 400 .erlang.cookie
随后,问题解决,可以正常启动mq了文章来源地址https://www.toymoban.com/news/detail-553719.html
[root@net-test-leel ~]# service rabbitmq-server restart
Redirecting to /bin/systemctl restart rabbitmq-server.service
到了这里,关于rabbitmq集群搭建报错:[error] Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!