rabbit启动:Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces auth.erl

avatar
作者
猴君
阅读量:4

背景:启动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. 

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  

从提供的日志错误信息来看,问题出现在读取 /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 

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

再次启动

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

到此成功!

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!