1, 感谢
http://www.rabbitmq.com/clustering.html
//www.greatytc.com/p/6376936845ff
2, rabbitmq-server -detached 报错解决
Warning: PID file not written; -detached was passed.
2018-11-13 09:18:57.417652
args: []
format: "Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only"
label: {error_logger,error_msg}
2018-11-13 09:18:57.417784 crash_report #{label=>{proc_lib,crash},report=>[[{initial_call,{auth,init,['Argument__1']}},{pid,<0.58.0>},{registered_name,[]},{error_info,{error,"Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only",[{auth,init_cookie,0,[{file,"auth.erl"},{line,286}]},{auth,init,1,[{file,"auth.erl"},{line,140}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,374}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,342}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]}},{ancestors,[net_sup,kernel_sup,<0.45.0>]},{message_queue_len,0},{messages,[]},{links,[<0.56.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_size,610},{stack_size,27},{reductions,538}],[]]} ......
解决方法
chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie
chmod 600 /var/lib/rabbitmq/.erlang.cookie
常用命令:
service rabbitmq-server status
--查看集群状态
rabbitmqctl cluster_status
rabbitmqctl stop_app
rabbitmqctl reset
--添加集群
rabbitmqctl join_cluster rabbit@rabbitmq1
rabbitmqctl start_app
--修改为内存节点(默认为磁盘节点): disc ram
rabbitmqctl change_cluster_node_type ram
注意事项
确保各个节点的cookie文件使用的是同一个值,某些工具在上传下载的时候会在文件后面自动追加换行.