RabbitMQ单机多实例配置(2)

rabbit2

[root@hiddenzhu-8drdc rabbitmq]# rabbitmqctl -n rabbit2 stop_app Stopping node 'rabbit2@hiddenzhu-8drdc' ... ...done. [root@hiddenzhu-8drdc rabbitmq]# rabbitmqctl -n rabbit2 reset Resetting node 'rabbit2@hiddenzhu-8drdc' ... ...done. [root@hiddenzhu-8drdc rabbitmq]# rabbitmqctl -n rabbit2 cluster rabbit1@`hostname -s` Clustering node 'rabbit2@hiddenzhu-8drdc' with ['rabbit1@hiddenzhu-8drdc'] ... ...done. [root@hiddenzhu-8drdc rabbitmq]# rabbitmqctl -n rabbit2 start_app Starting node 'rabbit2@hiddenzhu-8drdc' ... ...done.

TIPS
如果略去“rabbitmqctl -n rabbit2 reset”这一句,可能会报错:

Error: {ok,already_member}

查看cluster信息

[root@hiddenzhu-8drdc rabbitmq]# rabbitmqctl -n rabbit1 cluster_status Cluster status of node 'rabbit1@hiddenzhu-8drdc' ... [{nodes,[{disc,['rabbit1@hiddenzhu-8drdc']}, {ram,['rabbit2@hiddenzhu-8drdc']}]}, {running_nodes,['rabbit2@hiddenzhu-8drdc','rabbit1@hiddenzhu-8drdc']}] ...done. [root@hiddenzhu-8drdc rabbitmq]# rabbitmqctl -n rabbit2 cluster_status Cluster status of node 'rabbit2@hiddenzhu-8drdc' ... [{nodes,[{disc,['rabbit1@hiddenzhu-8drdc']}, {ram,['rabbit2@hiddenzhu-8drdc']}]}, {running_nodes,['rabbit1@hiddenzhu-8drdc','rabbit2@hiddenzhu-8drdc']}] ...done.

加入节点rabbit3

[root@hiddenzhu-8drdc rabbitmq]# RABBITMQ_NODE_PORT=5674 RABBITMQ_NODENAME=rabbit3 rabbitmq-server -detached Activating RabbitMQ plugins ... 0 plugins activated: [root@hiddenzhu-8drdc rabbitmq]# rabbitmqctl -n rabbit3 stop_app Stopping node 'rabbit3@hiddenzhu-8drdc' ... ...done. [root@hiddenzhu-8drdc rabbitmq]# rabbitmqctl -n rabbit3 reset Resetting node 'rabbit3@hiddenzhu-8drdc' ... ...done. [root@hiddenzhu-8drdc rabbitmq]# rabbitmqctl -n rabbit3 cluster rabbit1@`hostname -s` Clustering node 'rabbit3@hiddenzhu-8drdc' with ['rabbit1@hiddenzhu-8drdc'] ... ...done. [root@hiddenzhu-8drdc rabbitmq]# rabbitmqctl -n rabbit3 start_app Starting node 'rabbit3@hiddenzhu-8drdc' ... ...done.

最终查看集群状态

[root@hiddenzhu-8drdc rabbitmq]# rabbitmqctl -n rabbit3 cluster_status Cluster status of node 'rabbit3@hiddenzhu-8drdc' ... [{nodes,[{disc,['rabbit1@hiddenzhu-8drdc']}, {ram,['rabbit3@hiddenzhu-8drdc','rabbit2@hiddenzhu-8drdc']}]}, {running_nodes,['rabbit1@hiddenzhu-8drdc','rabbit2@hiddenzhu-8drdc', 'rabbit3@hiddenzhu-8drdc']}] ...done.

TIPS
有可能遇到这样的情况:

[root@hiddenzhu-8drdc rabbitmq]# rabbitmqctl status -n rabbit2 Status of node 'rabbit2@hiddenzhu-8drdc' ... Error: {badarith,[{rabbit_vm,bytes,1,[]}, {rabbit_vm,'-mnesia_memory/0-lc$^0/1-0-',1,[]}, {rabbit_vm,mnesia_memory,0,[]}, {rabbit_vm,memory,0,[]}, {rabbit,status,0,[]}, {rpc,'-handle_call_call/6-fun-0-',5, [{file,"rpc.erl"},{line,187}]}]}

有一种解决版本是将“/var/lib/rabbitmq/mnesia/”目录下的所有内容删掉(rm -rf *),然后重新启动再配置。

And….
很多时候也会遇到这样的情况:

[root@hiddenzhu-8drdc rabbitmq]# rabbitmqctl -n rabbit2 status Status of node 'rabbit2@hiddenzhu-8drdc' ... Error: unable to connect to node 'rabbit2@hiddenzhu-8drdc': nodedown diagnostics: - nodes and their ports on hiddenzhu-8drdc: [{rabbit1,44494}, {rabbitmqctl2271,60458}] - current node: 'rabbitmqctl2271@hiddenzhu-8drdc' - current node home dir: /root - current node cookie hash: VCwbL3S9/ydrGgVsrLjVkA==

这说明rabbitmq节点并未启动起来,需要进一步查看排除异常。

End…

CentOS 7.2 下 RabbitMQ 集群搭建

CentOS7环境安装使用专业的消息队列产品RabbitMQ

RabbitMQ入门教程 

在CentOS7上安装RabbitMQ 详解 

NServiceBus 结合 RabbitMQ 使用教程 

CentOS 7下RabbitMQ集群安装配置 

RabbitMQ实战:高效部署分布式消息队列 中文PDF扫描版 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5314229b0106196e42656d21598a59dd.html