笔者搭建了一个 RabbitMQ 集群,集群有三个节点,分别为 node1、node2 和 node3。通过 rabbitmqctl forget_cluster_node 命令将 node2 从集群中移除。移除成功后,重新启动 RabbitMQ 服务抛出“Node rabbit@node2 thinks it's clustered with node rabbit@node3, but rabbit@node3 disagrees”错误。
详细错误信息如下:
[root@node2 ~]# rabbitmq-server start 2022-04-06 22:18:22.963210+08:00 [info] <0.229.0> Feature flags: list of feature flags found: 2022-04-06 22:18:22.973590+08:00 [info] <0.229.0> Feature flags: [x] implicit_default_bindings 2022-04-06 22:18:22.973656+08:00 [info] <0.229.0> Feature flags: [x] maintenance_mode_status 2022-04-06 22:18:22.973678+08:00 [info] <0.229.0> Feature flags: [x] quorum_queue 2022-04-06 22:18:22.973695+08:00 [info] <0.229.0> Feature flags: [x] stream_queue 2022-04-06 22:18:22.973796+08:00 [info] <0.229.0> Feature flags: [x] user_limits 2022-04-06 22:18:22.973823+08:00 [info] <0.229.0> Feature flags: [x] virtual_host_metadata 2022-04-06 22:18:22.973845+08:00 [info] <0.229.0> Feature flags: feature flag states written to disk: yes 2022-04-06 22:18:23.252517+08:00 [noti] <0.44.0> Application syslog exited with reason: stopped 2022-04-06 22:18:23.252638+08:00 [noti] <0.229.0> Logging: switching to configured handler(s); following messages may not be visible in this log output BOOT FAILED =========== Error during startup: {error, {inconsistent_cluster, "Node rabbit@node2 thinks it's clustered with node rabbit@node3, but rabbit@node3 disagrees"}} {"Kernel pid terminated",application_controller,"{application_start_failure,rabbit,{{inconsistent_cluster,\"Node rabbit@node2 thinks it's clustered with node rabbit@node3, but rabbit@node3 disagrees\"},{rabbit,start,[normal,[]]}}}"} Kernel pid terminated (application_controller) ({application_start_failure,rabbit,{{inconsistent_cluster,"Node rabbit@node2 thinks it's clustered with node rabbit@node3, but rabbit@node3 disagrees"},{rabbit,start,[normal,[]]}}}) Crash dump is being written to: /var/log/rabbitmq/erl_crash.dump...done
从 rabbit@node2 的启动报错信息来看,像是 RabbitMQ 集群信息残留,导致服务启动失败。解决办法:
(1)进入到 /var/log/rabbitmq 目录
[root@node2 ~]# cd /var/log/rabbitmq
(2)将 mnesia 目录移动到 /tmp 目录,相当于删除该目录
[root@node2 rabbitmq]# mv mnesia/ /tmp/
(3)重新启动 RabbitMQ 服务
[root@node2 rabbitmq]# rabbitmq-server start 2022-04-06 22:23:01.092192+08:00 [info] <0.229.0> Feature flags: list of feature flags found: 2022-04-06 22:23:01.102281+08:00 [info] <0.229.0> Feature flags: [ ] implicit_default_bindings 2022-04-06 22:23:01.102345+08:00 [info] <0.229.0> Feature flags: [ ] maintenance_mode_status 2022-04-06 22:23:01.102368+08:00 [info] <0.229.0> Feature flags: [ ] quorum_queue 2022-04-06 22:23:01.102385+08:00 [info] <0.229.0> Feature flags: [ ] stream_queue 2022-04-06 22:23:01.102481+08:00 [info] <0.229.0> Feature flags: [ ] user_limits 2022-04-06 22:23:01.102512+08:00 [info] <0.229.0> Feature flags: [ ] virtual_host_metadata 2022-04-06 22:23:01.102535+08:00 [info] <0.229.0> Feature flags: feature flag states written to disk: yes 2022-04-06 22:23:01.414834+08:00 [noti] <0.44.0> Application syslog exited with reason: stopped 2022-04-06 22:23:01.414958+08:00 [noti] <0.229.0> Logging: switching to configured handler(s); following messages may not be visible in this log output ## ## RabbitMQ 3.9.14 ## ## ########## Copyright (c) 2007-2022 VMware, Inc. or its affiliates. ###### ## ########## Licensed under the MPL 2.0. Website: https://rabbitmq.com Erlang: 24.3.3 [jit] TLS Library: OpenSSL - OpenSSL 3.0.1 14 Dec 2021 Doc guides: https://rabbitmq.com/documentation.html Support: https://rabbitmq.com/contact.html Tutorials: https://rabbitmq.com/getstarted.html Monitoring: https://rabbitmq.com/monitoring.html Logs: /var/log/rabbitmq/rabbit@node2.log /var/log/rabbitmq/rabbit@node2_upgrade.log <stdout> Config file(s): /etc/rabbitmq/rabbitmq.config Starting broker... completed with 3 plugins.
可以看到,RabbitMQ 服务正常启动了。