FAQ: How to reset the RabbitMQ broker?

In some cases, you just need to wipe everything off from your RabbitMQ server and start over. Despite being extremely stable, in some rare circumstances, you will need to completely reset RabbitMQ after encountering errors such as corrupt data, nodes permanently separated from the cluster, or an unmanageably large broker.

The simple answer is to delete and recreate the vhost, that will permanently clear all entities like queues, policies, bindings, etc. So let’s start to tell how to do that, followed by information on how to use the reset and force_reset command.

Recreate the virtual host from the command line

You do not need to reset a RabbitMQ node to remove corrupted data. Dropping a virtual host removes data from the database while maintaining the cluster state and user information.

Enter the following commands to drop a vhost named reset_vhost:

delete_vhost reset_vhost
add_vhost reset_vhost

These commands simply drop and add the reset_vhost. All related queues, exchanges, and messages drop from the broker without affecting users.

Recreate the virtual host from the management console

The management console allows administrators to delete and create virtual hosts without using the command line. If using CloudAMQP, you will need a dedicated plan to access the Admin tab. As an example we have have a queue reset_queue, and an attached exchange, reset_exchange.

The queue and exchange reside under the vhost named reset_vhost as shown in the figure below:

Click on the vhost reset_vhost at the /vhosts path and then on the Delete this Virtual Host button at the bottom of the page. Click ok if prompted by RabbitMQ.

The broker will drop the vhost and any related structure. The action does not affect the attached users, it merely removes the vhost.

How do I reset my RabbitMQ node?

RabbitMQ offers the reset and force_reset command through rabbitmqctl to reset a single node. Open a new shell on the server hosting the node and type the following commands to gracefully reset the server:

rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app

You must stop the server to use this command, restarting once complete. The broker drops all virtual hosts, queues, exchanges, and non-administrative users. RabbitMQ attempts to gracefully exit without damaging an existing cluster or broker, returning to a virgin state.

What do I do if my RabbitMQ cluster becomes corrupted?

If your cluster is corrupted or irreparably split, use force_reset instead of reset. This will automatically drop your queues, exchanges, and configurations. Run the following from a command-line shell on the target node:

rabbitmqctl stop_app
rabbitmqctl force_reset
rabbitmqctl start_app

You still need to stop and restart the application. Only use this command as a last resort, when the database or cluster is corrupted, as there is no attempt to notify other nodes. Any reset command results in the removal of all users except for the administrative user and any messages.

What happens if I drop a vhost on a cluster node?

Clusters attempt to synchronize information. If you reset a virtual host, the action propagates across the cluster. All brokers drop related queues, exchanges, and messages as well.

Resetting a node drops it from the cluster. The vhost and related information remain on the cluster. You will need to drop vhosts on the cluster as needed. If you do not drop the vhost, it is recreated when rejoining the cluster.

Feedback

If you have any questions, suggestions, comments, or even a stuck rabbit, please comment below and we will get back to you.

CloudAMQP - industry leading RabbitMQ as a service

Start your managed cluster today. CloudAMQP is 100% free to try.

13,000+ users including these smart companies