当前位置:   article > 正文

rabbit启动:Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces auth.erl_-- logs begin at sun 2024-07-14 19:15:12 sst, end

-- logs begin at sun 2024-07-14 19:15:12 sst, end at sun 2024-07-14 19:32:05

背景:启动rabbitmq错误

[root@10-61-82-173 ~]# systemctl restart rabbitmq-server
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.
  • 1
  • 2

journalctl -u rabbitmq-server.service 查看系统日志

[root@10-61-82-173 ~]# journalctl -u rabbitmq-server.service
-- Logs begin at 四 2024-07-11 00:17:32 PDT, end at 四 2024-07-11 22:46:26 PDT. --
711 21:05:17 10-61-82-173 systemd[1]: Starting RabbitMQ broker...
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: 2024-07-11 21:05:18 Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: 2024-07-11 21:05:18 crash_report
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: initial_call: {auth,init,['Argument__1']}
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: pid: <0.48.0>
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: registered_name: []
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: error_info: {error,"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",[{auth,init_cookie,0,[{file,"auth.erl"},{line,286}]},{aut
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: ancestors: [net_sup,kernel_sup,<0.36.0>]
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: message_queue_len: 0
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: messages: []
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: links: [<0.46.0>]
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: dictionary: []
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: trap_exit: true
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: status: running
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: heap_size: 610
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: stack_size: 27
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: reductions: 954
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: 2024-07-11 21:05:18 supervisor_report
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: supervisor: {local,net_sup}
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: errorContext: start_error
711 21:05:18 10-61-82-173 rabbitmq-server[14026]:` reason: {"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",[{auth,init_cookie,0,[{file,"auth.erl"},{line,286}]},{auth,init,1,[
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: offender: [{pid,undefined},{id,auth},{mfargs,{auth,start_link,[]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: 2024-07-11 21:05:18 supervisor_report
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: supervisor: {local,kernel_sup}
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: errorContext: start_error
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: reason: {shutdown,{failed_to_start_child,auth,{"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",[{auth,init_cookie,0,[{file,"
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: offender: [{pid,undefined},{id,net_sup},{mfargs,{erl_distribution,start_link,[]}},{restart_type,permanent},{shutdown,infinity},{child_type
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: 2024-07-11 21:05:18 crash_report

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

从提供的日志错误信息来看,问题出现在读取 /var/lib/rabbitmq/.erlang.cookie 文件时出现了权限错误(eacces),这通常意味着 Erlang 节点尝试读取 .erlang.cookie 文件时没有足够的权限。

.erlang.cookie 文件对 Erlang 节点之间的通信至关重要,因为它包含了节点间的认证信息。当多个 Erlang 节点需要集群时,它们必须共享相同的 .erlang.cookie 文件内容。文件权限问题可能会阻止 Erlang 节点正常启动或集群。

为了解决这个问题,你需要确保 Erlang 节点运行的用户(通常是 rabbitmq 用户)具有读取 .erlang.cookie 文件的权限。以下是几个可能的解决方案:

更改文件权限
更改 .erlang.cookie 文件的权限,让 rabbitmq 用户能够读取它。使用以下命令:

sudo chmod 600 /var/lib/rabbitmq/.erlang.cookie
sudo chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie
  • 1
  • 2

第一个命令确保文件只有拥有者可以读写,第二个命令将文件的所有权设置为 rabbitmq 用户和组。

再次启动

[root@10-61-82-173 ~]# systemctl restart rabbitmq-server

  • 1
  • 2
[root@10-61-82-173 ~]# journalctl -u rabbitmq-server.service
-- Logs begin at 四 2024-07-11 00:17:32 PDT, end at 四 2024-07-11 22:55:44 PDT. --
711 21:05:17 10-61-82-173 systemd[1]: Starting RabbitMQ broker...
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: 2024-07-11 21:05:18 Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: 2024-07-11 21:05:18 crash_report
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: initial_call: {auth,init,['Argument__1']}
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: pid: <0.48.0>
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: registered_name: []
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: error_info: {error,"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",[{auth,init_cookie,0,[{file,"auth.erl"},{line,286}]},{aut
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: ancestors: [net_sup,kernel_sup,<0.36.0>]
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: message_queue_len: 0
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: messages: []
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: links: [<0.46.0>]
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: dictionary: []
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: trap_exit: true
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: status: running
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: heap_size: 610
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: stack_size: 27
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: reductions: 954
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: 2024-07-11 21:05:18 supervisor_report
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: supervisor: {local,net_sup}
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: errorContext: start_error
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: reason: {"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",[{auth,init_cookie,0,[{file,"auth.erl"},{line,286}]},{auth,init,1,[
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: offender: [{pid,undefined},{id,auth},{mfargs,{auth,start_link,[]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: 2024-07-11 21:05:18 supervisor_report
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: supervisor: {local,kernel_sup}
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: errorContext: start_error
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: reason: {shutdown,{failed_to_start_child,auth,{"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",[{auth,init_cookie,0,[{file,"
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: offender: [{pid,undefined},{id,net_sup},{mfargs,{erl_distribution,start_link,[]}},{restart_type,permanent},{shutdown,infinity},{child_type
711 21:05:18 10-61-82-173 rabbitmq-server[14026]: 2024-07-11 21:05:18 crash_report
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

到此成功!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/836231
推荐阅读
相关标签
  

闽ICP备14008679号