集群中node必须使用相同的cookie才能相互通讯
在Linux中cookie的位置一般在 /var/lib/rabbitmq/.erlang.cookie
[root@new-mq-node rabbitmq]# vim .erlang.cookie
[root@new-mq-node rabbitmq]# cat .erlang.cookie
ABCDEFGGTESTGNUMPXYZ
[root@new-mq-node rabbitmq]#
Note: 一定要确保所有node上的cookie内容相同,并且为所有者只读
如果 .erlang.cookie 不为所有者只读,启动时会报如下错误
[root@new-mq-node rabbitmq]# ll .erlang.cookie
-rw-r--r-- 1 rabbitmq rabbitmq 21 Jan 13 14:08 .erlang.cookie
[root@new-mq-node rabbitmq]# /etc/init.d/rabbitmq-server start
Starting rabbitmq-server: FAILED - check /var/log/rabbitmq/startup_{log, _err}
rabbitmq-server.
[root@new-mq-node rabbitmq]# cd /var/log/rabbitmq/
[root@new-mq-node rabbitmq]# ls
startup_err startup_log
[root@new-mq-node rabbitmq]# tail startup_err
Crash dump was written to: erl_crash.dump
Kernel pid terminated (application_controller) ({application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]\}\}})
[root@new-mq-node rabbitmq]# tail startup_log
{error_logger,\{\{2016,1,13},{14,22,17\}\},"Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only",[]}
{error_logger,\{\{2016,1,13},{14,22,17\}\},crash_report,[[{initial_call,{auth,init,['Argument__1']\}\},{pid,<0.19.0>},{registered_name,[]},{error_info,{exit,{"Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only",[{auth,init_cookie,0},{auth,init,1},{gen_server,init_it,6},{proc_lib,init_p_do_apply,3}]},[{gen_server,init_it,6},{proc_lib,init_p_do_apply,3}]\}\},{ancestors,[net_sup,kernel_sup,<0.9.0>]},{messages,[]},{links,[<0.17.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_size,987},{stack_size,24},{reductions,428}],[]]}
{error_logger,\{\{2016,1,13},{14,22,17\}\},supervisor_report,[{supervisor,{local,net_sup\}\},{errorContext,start_error},{reason,{"Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only",[{auth,init_cookie,0},{auth,init,1},{gen_server,init_it,6},{proc_lib,init_p_do_apply,3}]\}\},{offender,[{pid,undefined},{name,auth},{mfargs,{auth,start_link,[]\}\},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]}
{error_logger,\{\{2016,1,13},{14,22,17\}\},supervisor_report,[{supervisor,{local,kernel_sup\}\},{errorContext,start_error},{reason,shutdown},{offender,[{pid,undefined},{name,net_sup},{mfargs,{erl_distribution,start_link,[]\}\},{restart_type,permanent},{shutdown,infinity},{child_type,supervisor}]}]}
{error_logger,\{\{2016,1,13},{14,22,17\}\},std_info,[{application,kernel},{exited,{shutdown,{kernel,start,[normal,[]]\}\}},{type,permanent}]}
{"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]\}\}}"}
[root@new-mq-node rabbitmq]#
解决办法是修改权限成为 -r--------
[root@new-mq-node rabbitmq]# chmod 400 .erlang.cookie
[root@new-mq-node rabbitmq]# ll .erlang.cookie
-r-------- 1 rabbitmq rabbitmq 21 Jan 13 14:08 .erlang.cookie
[root@new-mq-node rabbitmq]#
再次尝试就能成功启动
[root@new-mq-node rabbitmq]# /etc/init.d/rabbitmq-server start
Starting rabbitmq-server: SUCCESS
rabbitmq-server.
[root@new-mq-node rabbitmq]# /etc/init.d/rabbitmq-server status
Status of node 'rabbit@new-mq-node' ...
...
...
[root@new-mq-node rabbitmq]# netstat -ant | grep 5672
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN
tcp 0 0 :::5672 :::* LISTEN
[root@new-mq-node rabbitmq]#
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。