我在 3 个服务器上运行 RabbitMQ,相同版本的 Erlang 和 RabbitMQ:RabbitMQ 3.4.1,Erlang 17.3
一个节点在服务器 2 上崩溃。另外两个节点没有连接在一起:
服务器 1:
[CentOS-62-64-minimal ~]$ sudo rabbitmqctl cluster_status
Cluster status of node 'rabbit@CentOS-62-64-minimal' ...
[{nodes,[{disc,['rabbit@CentOS-62-64-minimal',rabbit@de3,rabbit@mysql]}]},
{running_nodes,['rabbit@CentOS-62-64-minimal']},
{cluster_name,<<"rabbit@CentOS-62-64-minimal">>},
{partitions,[]}]
服务器 3:
[de3 ~]$ sudo rabbitmqctl cluster_status
Cluster status of node rabbit@de3 ...
[{nodes,[{disc,['rabbit@CentOS-62-64-minimal',rabbit@de3,rabbit@mysql]}]},
{running_nodes,[rabbit@de3]},
{cluster_name,<<"rabbit@CentOS-62-64-minimal">>},
{partitions,[]}]
在服务器 3 上重启并重置 rabbitmq 后,终于连接到了 server1:
[CentOS-62-64-minimal ~]$ sudo rabbitmqctl cluster_status
Cluster status of node 'rabbit@CentOS-62-64-minimal' ...
[{nodes,[{disc,['rabbit@CentOS-62-64-minimal',rabbit@de3,rabbit@mysql]}]},
{running_nodes,['rabbit@CentOS-62-64-minimal']},
{cluster_name,<<"rabbit@CentOS-62-64-minimal">>},
{partitions,[]}]
为什么只有 1 个节点停机时集群会“崩溃”?服务器 3 工作正常,但服务器 1 不是:“队列位于已关闭的服务器上”。
至于服务器 2,它没有重新启动。手动重启后,我无法让它重新连接到集群,即使在多次重置和删除 /var/lib/rabbitmq/mnesia/ 之后也是如此:
[root@mysql ~]# rabbitmqctl cluster_status
Cluster status of node rabbit@mysql ...
[{nodes,[{disc,[rabbit@mysql]}]},
{running_nodes,[rabbit@mysql]},
{cluster_name,<<"[email protected]">>},
{partitions,[]}]
[mysql ~]# rabbitmqctl stop_app
Stopping node rabbit@mysql ...
[root@mysql ~]# rabbitmqctl force_reset
Forcefully resetting node rabbit@mysql ...
[ysql ~]# rabbitmqctl join_cluster rabbit@CentOS-62-64-minimal
Clustering node rabbit@mysql with 'rabbit@CentOS-62-64-minimal' ...
Error: {ok,already_member}
[mysql ~]# rabbitmqctl start_app
Starting node rabbit@mysql ...
[mysql ~]# rabbitmqctl cluster_status
Cluster status of node rabbit@mysql ...
[{nodes,[{disc,[rabbit@mysql]}]},
{running_nodes,[rabbit@mysql]},
{cluster_name,<<"[email protected]">>},
{partitions,[]}]
我不知道出了什么问题。上次发生这种情况时,我将 RabbitMQ qnd Erlang 升级到了最新版本。