RabbitMQ: remove node from cluster

RabbitMQWhen a node is no longer meant to be part of a RabbitMQ cluster, we’d remove it explicitly from the cluster. To remove a node from a cluster, there are basically two ways, get itself remove locally, or remove it remotely from the reset nodes.

Here suppose we have a cluster consist of three RabbitMQ nodes rabbit@node1,rabbit@node2, and rabbit@node3, let’s remove one node as an example.

Remove itself from local side

To do that, on rabbit@node3 we stop the RabbitMQ application, then reset the node, and restart the RabbitMQ application, as follows,

rabbit3$ rabbitmqctl stop_app
Stopping node rabbit@node3 ...done.
rabbit3$ rabbitmqctl reset
Resetting node rabbit@node3 ...done.
rabbit3$ rabbitmqctl start_app
Starting node rabbit@node3 ...done.

Note that it would have been equally valid to list rabbit@rabbit3 as a node.

Running the cluster_status command on the nodes confirms that rabbit@node3 now is no longer part of the cluster and operates independently:

node1$ rabbitmqctl cluster_status
Cluster status of node rabbit@node1 ...
node2$ rabbitmqctl cluster_status
Cluster status of node rabbit@node2 ...
node3$ rabbitmqctl cluster_status
Cluster status of node rabbit@node3 ...

Remove a node from cluster remotely

This is useful, for example, when having to deal with an unresponsive rabbitmq node. We can for example remove rabbit@node2 from a cluster consist of two nodes: node1 and node2.

node1$ rabbitmqctl forget_cluster_node rabbit@node2
Removing node rabbit@node2 from cluster ...

Note that node2 still thinks its clustered with the other nodes, and trying to start it will result in an error. We will need to reset it to be able to start it again.

node2$ rabbitmqctl start_app
Starting node rabbit@node2 ...
Error: inconsistent_cluster: Node rabbit@node1 thinks it's clustered with node rabbit@node2, but rabbit@node2 disagrees
node2$ rabbitmqctl reset
Resetting node rabbit@node2 ...done.
Share Button

Leave a comment

Your email address will not be published. Required fields are marked *