centos 安装rabbitmq遇见 Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces

原创
2018/03/20 17:30
阅读数 2.7W

centos 安装rabbitmq

  • 首先安装erlang

下载rpm仓库:wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm

安装rpm仓库 rpm -Uvh erlang-solutions-1.0-1.noarch.rpm

安装erlang yum -y install erlang

安装完成后 运行erl -v
Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V9.3  (abort with ^G)
1>
  • 安装rabbitmq

下载页面 中选择

yum -y install 具体的版本号

  • 运行

systemctl start 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" f

stemctl 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 Tue 2018-03-20 16:40:20 CST; 3s ago
  Process: 27573 ExecStop=/usr/sbin/rabbitmqctl shutdown (code=exited, status=78)
  Process: 27390 ExecStart=/usr/sbin/rabbitmq-server (code=exited, status=1/FAILURE)
 Main PID: 27390 (code=exited, status=1/FAILURE)

Mar 20 16:40:20 vdevops systemd[1]: Failed to start RabbitMQ broker.
Mar 20 16:40:20 vdevops systemd[1]: Unit rabbitmq-server.service entered failed state.
Mar 20 16:40:20 vdevops systemd[1]: rabbitmq-server.service failed.

查看具体错误

journalctl -xe
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: links: [<0.46.0>]
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: dictionary: []
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: trap_exit: true
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: status: running
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: heap_size: 610
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: stack_size: 27
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: reductions: 954
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: 2018-03-20 16:43:36 supervisor_report
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: supervisor: {local,net_sup}
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: errorContext: start_error
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: reason: {"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",[{auth,init_cookie,0,[{file,"auth.erl"},{li
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: offender: [{pid,undefined},{id,auth},{mfargs,{auth,start_link,[]}},{restart_type,permanent},{shutdown,2000},{child
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: 2018-03-20 16:43:36 supervisor_report
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: supervisor: {local,kernel_sup}
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: errorContext: start_error
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: reason: {shutdown,{failed_to_start_child,auth,{"Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces",[{aut
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: offender: [{pid,undefined},{id,net_sup},{mfargs,{erl_distribution,start_link,[]}},{restart_type,permanent},{shutdo
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: 2018-03-20 16:43:36 crash_report
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: initial_call: {application_master,init,['Argument__1','Argument__2','Argument__3','Argument__4']}
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: pid: <0.35.0>
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: registered_name: []
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: error_info: {exit,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,auth,{"Error when rea
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: ancestors: [<0.34.0>]
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: message_queue_len: 1
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: messages: [{'EXIT',<0.36.0>,normal}]
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: links: [<0.34.0>,<0.33.0>]
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: dictionary: []
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: trap_exit: true
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: status: running
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: heap_size: 987
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: stack_size: 27
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: reductions: 250
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: 2018-03-20 16:43:36 std_info
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: application: kernel
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: exited: {{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,auth,{"Error when reading /var/
Mar 20 16:43:36 vdevops rabbitmq-server[1578]: type: permanent
Mar 20 16:43:37 vdevops rabbitmq-server[1578]: {"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{{shutdown,{failed_to_start_chi
Mar 20 16:43:37 vdevops rabbitmq-server[1578]: Kernel pid terminated (application_controller) ({application_start_failure,kernel,{{shutdown,{failed_to_start_chil
Mar 20 16:43:37 vdevops rabbitmq-server[1578]: Crash dump is being written to: /var/log/rabbitmq/erl_crash.dump...done
Mar 20 16:43:37 vdevops systemd[1]: rabbitmq-server.service: main process exited, code=exited, status=1/FAILURE
Mar 20 16:43:37 vdevops rabbitmqctl[1761]: 16:43:37.884 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
Mar 20 16:43:38 vdevops rabbitmqctl[1761]: 16:43:38.769 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
Mar 20 16:43:38 vdevops rabbitmqctl[1761]: 16:43:38.770 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
Mar 20 16:43:39 vdevops rabbitmqctl[1761]: 16:43:39.659 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
Mar 20 16:43:39 vdevops rabbitmqctl[1761]: 16:43:39.660 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
Mar 20 16:43:40 vdevops rabbitmqctl[1761]: 16:43:40.553 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
Mar 20 16:43:40 vdevops rabbitmqctl[1761]: 16:43:40.554 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
Mar 20 16:43:41 vdevops rabbitmqctl[1761]: 16:43:41.450 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
Mar 20 16:43:41 vdevops rabbitmqctl[1761]: 16:43:41.450 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
Mar 20 16:43:42 vdevops rabbitmqctl[1761]: 16:43:42.347 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
Mar 20 16:43:42 vdevops rabbitmqctl[1761]: 16:43:42.347 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
Mar 20 16:43:43 vdevops rabbitmqctl[1761]: 16:43:43.241 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces
Mar 20 16:43:43 vdevops rabbitmqctl[1761]: 16:43:43.242 [error] Error when reading /var/lib/rabbitmq/.erlang.cookie: eacces

错误日志显示访问问题,查询资料可能是权限问题。

chmod +x .erlang.cookie 重复上诉操作,错误改为:

Mar 20 16:54:59 vdevops rabbitmqctl[22540]: 16:54:59.815 [error] Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only
Mar 20 16:54:59 vdevops rabbitmqctl[22540]: 16:54:59.815 [error] Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only
Mar 20 16:55:00 vdevops rabbitmqctl[22540]: 16:55:00.721 [error] Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only
Mar 20 16:55:00 vdevops rabbitmqctl[22540]: 16:55:00.722 [error] Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only
Mar 20 16:55:01 vdevops rabbitmqctl[22540]: 16:55:01.632 [error] Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only
Mar 20 16:55:01 vdevops rabbitmqctl[22540]: Distribution failed: {{:shutdown, {:failed_to_start_child, :auth, {'Cookie file /var/lib/rabbitmq/.erlang.cookie mus
Mar 20 16:55:01 vdevops systemd[1]: rabbitmq-server.service: control process exited, code=exited status=78
Mar 20 16:55:01 vdevops systemd[1]: Failed to start RabbitMQ broker.
-- Subject: Unit rabbitmq-server.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

修改权限

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

再次运行,成功。

展开阅读全文
加载中

作者的其它热门文章

打赏
1
0 收藏
分享
打赏
0 评论
0 收藏
1
分享
返回顶部
顶部