rabbitmqctl — tool for managing RabbitMQ nodes
rabbitmqctl | [-q] [-s] [-l] [-n node] [-t timeout] command [command_options] |
RabbitMQ is an open source multi-protocol messaging broker.
rabbitmqctl is the main command line tool for managing a RabbitMQ server node, together with rabbitmq-diagnostics , rabbitmq-upgrade , and others.
It performs all actions by connecting to the target RabbitMQ node on a dedicated CLI tool communication port and authenticating using a shared secret (known as the cookie file).
Diagnostic information is displayed if connection failed, the target node was not running, or rabbitmqctl could not authenticate to the target node successfully.
To learn more, see the RabbitMQ CLI Tools guide
Prints usage for all available commands.
Displays CLI tools version
Waits for the RabbitMQ application to start on the target node
For example, to wait for the RabbitMQ application to start:
Returns a RabbitMQ node to its virgin state.
Removes the node from any cluster it belongs to, removes all data from the management database, such as configured users and vhosts, and deletes all persistent messages.
For reset and force_reset to succeed the RabbitMQ application must have been stopped, e.g. with stop_app.
For example, to reset the RabbitMQ node:
Instructs the RabbitMQ node to perform internal log rotation.
Log rotation is performed according to the logging settings specified in the configuration file. The rotation operation is asynchronous, there is no guarantee that it has completed when this command returns.
Note that there is no need to call this command in case of external log rotation (e.g. from logrotate(8)).
For example, to initial log rotation:
Shuts down the node, both RabbitMQ and its runtime. The command is blocking and will return after the runtime process exits. If RabbitMQ fails to stop, it will return a non-zero exit code. This command infers the OS PID of the target node and therefore can only be used to shut down nodes running on the same host (or broadly speaking, in the same operating system, e.g. in the same VM or container)
Unlike the stop command, the shutdown command:
For example, this will shut down a locally running RabbitMQ node with default node name:
Starts the RabbitMQ application.
This command is typically run after performing other management actions that required the RabbitMQ application to be stopped, e.g. reset.
For example, to instruct the RabbitMQ node to start the RabbitMQ application:
Stops the Erlang node on which RabbitMQ is running. To restart the node follow the instructions for "Running the Server" in the installation guide.
If a pid_file is specified, also waits for the process specified there to terminate. See the description of the wait command for details on this file.
For example, to instruct the RabbitMQ node to terminate:
Stops the RabbitMQ application, leaving the runtime (Erlang VM) running.
This command is typically run prior to performing other management actions that require the RabbitMQ application to be stopped, e.g. reset.
For example, to instruct the RabbitMQ node to stop the RabbitMQ application:
Waits for the RabbitMQ application to start.
This command will wait for the RabbitMQ application to start at the node. It will wait for the pid file to be created if pidfile is specified, then for a process with a pid specified in the pid file or the --pid argument, and then for the RabbitMQ application to start in that process. It will fail if the process terminates without starting the RabbitMQ application.
If the specified pidfile is not created or erlang node is not started within --timeout the command will fail. Default timeout is 10 seconds.
A suitable pid file is created by the rabbitmq-server(8) script. By default this is located in the Mnesia directory. Modify the RABBITMQ_PID_FILE environment variable to change the location.
For example, this command will return when the RabbitMQ node has started up:
Waits for count nodes to join the cluster
For example, to wait for two RabbitMQ nodes to start:
Changes the type of the cluster node.
The type must be one of the following:
The node must be stopped for this operation to succeed, and when turning a node into a RAM node the node must not be the only disc node in the cluster.
For example, this command will turn a RAM node into a disc node:
Displays all the nodes in the cluster grouped by node type, together with the currently running nodes.
For example, this command displays the nodes in the cluster:
Ensures that the node will start next time, even if it was not the last to shut down.
Normally when you shut down a RabbitMQ cluster altogether, the first node you restart should be the last one to go down, since it may have seen things happen that other nodes did not. But sometimes that's not possible: for instance if the entire cluster loses power then all nodes may think they were not the last to shut down.
In such a case you can invoke force_boot while the node is down. This will tell the node to unconditionally start next time you ask it to. If any changes happened to the cluster after this node shut down, they will be lost.
If the last node to go down is permanently lost then you should use forget_cluster_node --offline in preference to this command, as it will ensure that mirrored queues which had their leader replica on the lost node get promoted.
For example, this will force the node not to wait for other nodes next time it is started:
Forcefully returns a RabbitMQ node to its virgin state.
The force_reset command differs from reset in that it resets the node unconditionally, regardless of the current management database state and cluster configuration. It should only be used as a last resort if the database or cluster configuration has been corrupted.
For reset and force_reset to succeed the RabbitMQ application must have been stopped, e.g. with stop_app.
For example, to reset the RabbitMQ node:
Removes a cluster node remotely. The node that is being removed must be offline, while the node we are removing from must be online, except when using the --offline flag.
When using the --offline flag , rabbitmqctl will not attempt to connect to a node as normal; instead it will temporarily become the node in order to make the change. This is useful if the node cannot be started normally. In this case the node will become the canonical source for cluster metadata (e.g. which queues exist), even if it was not before. Therefore you should use this command on the latest node to shut down if at all possible.
For example, this command will remove the node "rabbit@stringer" from the node "hare@mcnulty":
Instructs the node to become a member of the cluster that the specified node is in. Before clustering, the node is reset, so be careful when using this command. For this command to succeed the RabbitMQ application must have been stopped, e.g. with stop_app.
Cluster nodes can be of two types: disc or RAM. Disc nodes replicate data in RAM and on disc, thus providing redundancy in the event of node failure and recovery from global events such as power failure across all nodes. RAM nodes replicate data in RAM only (with the exception of queue contents, which can reside on disc if the queue is persistent or too big to fit in memory) and are mainly used for scalability. RAM nodes are more performant only when managing resources (e.g. adding/removing queues, exchanges, or bindings). A cluster must always have at least one disc node, and usually should have more than one.
The node will be a disc node by default. If you wish to create a RAM node, provide the --ram flag.
After executing the join_cluster command, whenever the RabbitMQ application is started on the current node it will attempt to connect to the nodes that were in the cluster when the node went down.
To leave a cluster, reset the node. You can also remove nodes remotely with the forget_cluster_node command.
For example, this command instructs the RabbitMQ node to join the cluster that "hare@elena" is part of, as a ram node:
To learn more, see the RabbitMQ Clustering guide.
Supports renaming of cluster nodes in the local database.
This subcommand causes rabbitmqctl to temporarily become the node in order to make the change. The local cluster node must therefore be completely stopped; other nodes can be online or offline.
This subcommand takes an even number of arguments, in pairs representing the old and new names for nodes. You must specify the old and new names for this node and for any other nodes that are stopped and being renamed at the same time.
It is possible to stop all nodes and rename them all simultaneously (in which case old and new names for all nodes must be given to every node) or stop and rename nodes one at a time (in which case each node only needs to be told how its own name is changing).
For example, this command will rename the node "rabbit@misshelpful" to the node "rabbit@cordelia"
Note that this command only changes the local database. It may also be necessary to rename the local database directories, and to configure the new node name. For example:
mv \ /var/lib/rabbitmq/mnesia/rabbit\@misshelpful \ /var/lib/rabbitmq/mnesia/rabbit\@cordelia mv \ /var/lib/rabbitmq/mnesia/rabbit\@misshelpful-rename \ /var/lib/rabbitmq/mnesia/rabbit\@cordelia-rename mv \ /var/lib/rabbitmq/mnesia/rabbit\@misshelpful-plugins-expand \ /var/lib/rabbitmq/mnesia/rabbit\@cordelia-plugins-expand
Instructs an already clustered node to contact clusternode to cluster when booting up. This is different from join_cluster since it does not join any cluster - it checks that the node is already in a cluster with clusternode.
The need for this command is motivated by the fact that clusters can change while a node is offline. Consider a situation where node rabbit@A and rabbit@B are clustered. rabbit@A goes down, rabbit@C clusters with rabbit@B, and then rabbit@B leaves the cluster. When rabbit@A starts back up, it'll try to contact rabbit@B, but this will fail since rabbit@B is not in the cluster anymore. The following command will rename node rabbit@B to rabbit@C on node rabbitA
To learn more, see the RabbitMQ Clustering guide
Instructs a mirrored queue with unsynchronised mirrors (follower replicas) to synchronise them. The queue will block while synchronisation takes place (all publishers to and consumers using the queue will block or temporarily see no activity). This command can only be used with mirrored queues. To learn more, see the RabbitMQ Mirroring guide
Note that queues with unsynchronised replicas and active consumers will become synchronised eventually (assuming that consumers make progress). This command is primarily useful for queues which do not have active consumers.
Instructs a synchronising mirrored queue to stop synchronising itself.
Note that all user management commands rabbitmqctl only can manage users in the internal RabbitMQ database. Users from any alternative authentication backends such as LDAP cannot be inspected or managed with those commands. rabbitmqctl.
For example, this command instructs the RabbitMQ broker to create a (non-administrative) user named "janeway" with (initial) password "changeit":
For example, this command instructs the RabbitMQ broker to authenticate the user named "janeway" with password "verifyit":
For example, this command instructs the RabbitMQ broker to change the password for the user named "janeway" to "newpass":
For example, this command instructs the RabbitMQ broker to clear the password for the user named "janeway":
This user now cannot log in with a password (but may be able to through e.g. SASL EXTERNAL if configured).
For example, this command instructs the RabbitMQ broker to delete the user named "janeway":
Lists users. Each result row will contain the user name followed by a list of the tags set for that user.
For example, this command instructs the RabbitMQ broker to list all users:
For example, this command instructs the RabbitMQ broker to ensure the user named "janeway" is an administrator:
This has no effect when the user authenticates using a messaging protocol, but can be used to permit the user to manage users, virtual hosts and permissions when the user logs in via some other means (for example with the management plugin).
This command instructs the RabbitMQ broker to remove any tags from the user named "janeway":
Sets user permissions.
For example, this command instructs the RabbitMQ broker to deny the user named "janeway" access to the virtual host called "my-vhost":
Clear user topic permissions.
For example, this command instructs the RabbitMQ broker to remove topic permissions for user named "janeway" for the topic exchange "amq.topic" in the virtual host called "my-vhost":
Lists permissions in a virtual host.
For example, this command instructs the RabbitMQ broker to list all the users which have been granted access to the virtual host called "my-vhost", and the permissions they have for operations on resources in that virtual host. Note that an empty string means no permissions granted:
Lists topic permissions in a virtual host.
For example, this command instructs the RabbitMQ broker to list all the users which have been granted topic permissions in the virtual host called "my-vhost:"
Lists user permissions.
For example, this command instructs the RabbitMQ broker to list all the virtual hosts to which the user named "janeway" has been granted access, and the permissions the user has for operations on resources in these virtual hosts:
Lists user topic permissions.
For example, this command instructs the RabbitMQ broker to list all the virtual hosts to which the user named "janeway" has been granted access, and the topic permissions the user has in these virtual hosts:
Lists virtual hosts.
The vhostinfoitem parameter is used to indicate which virtual host information items to include in the results. The column order in the results will match the order of the parameters. vhostinfoitem can take any value from the list that follows:
If no vhostinfoitem are specified then the vhost name is displayed.
For example, this command instructs the RabbitMQ broker to list all virtual hosts:
Sets user permissions.
For example, this command instructs the RabbitMQ broker to grant the user named "janeway" access to the virtual host called "my-vhost", with configure permissions on all resources whose names starts with "janeway-", and write and read permissions on all resources:
Sets user topic permissions.
For example, this command instructs the RabbitMQ broker to let the user named "janeway" publish and consume messages going through the "amp.topic" exchange of the "my-vhost" virtual host with a routing key starting with "janeway-":
Topic permissions support variable expansion for the following variables: username, vhost, and client_id. Note that client_id is expanded only when using MQTT. The previous example could be made more generic by using "^{username}-.*":
Displays the name and value of each variable in the application environment for each running application.
Returns binding details. By default the bindings for the "/" virtual host are returned. The -p flag can be used to override this default.
The bindinginfoitem parameter is used to indicate which binding information items to include in the results. The column order in the results will match the order of the parameters. bindinginfoitem can take any value from the list that follows:
If no bindinginfoitem are specified then all above items are displayed.
For example, this command displays the exchange name and queue name of the bindings in the virtual host named "my-vhost"
Returns information on all current channels, the logical containers executing most AMQP commands. This includes channels that are part of ordinary AMQP connections, and channels created by various plug-ins and other extensions.
The channelinfoitem parameter is used to indicate which channel information items to include in the results. The column order in the results will match the order of the parameters. channelinfoitem can take any value from the list that follows:
If no channelinfoitem are specified then pid, user, consumer_count, and messages_unacknowledged are assumed.
For example, this command displays the connection process and count of unacknowledged messages for each channel:
Lists cipher suites supported by encoding commands.
For example, this command instructs the RabbitMQ broker to list all cipher suites supported by encoding commands:
Returns TCP/IP connection statistics.
The connectioninfoitem parameter is used to indicate which connection information items to include in the results. The column order in the results will match the order of the parameters. connectioninfoitem can take any value from the list that follows:
Note that if a client requests an AMQP 0-9 connection, we treat it as AMQP 0-9-1.
If no connectioninfoitem are specified then user, peer host, peer port, time since flow control and memory block state are displayed.
For example, this command displays the send queue size and server port for each connection:
Lists consumers, i.e. subscriptions to a queue´s message stream. Each line printed shows, separated by tab characters, the name of the queue subscribed to, the id of the channel process via which the subscription was created and is managed, the consumer tag which uniquely identifies the subscription within a channel, a boolean indicating whether acknowledgements are expected for messages delivered to this consumer, an integer indicating the prefetch limit (with 0 meaning "none"), and any arguments for this consumer.
Returns exchange details. Exchange details of the "/" virtual host are returned if the -p flag is absent. The -p flag can be used to override this default.
The exchangeinfoitem parameter is used to indicate which exchange information items to include in the results. The column order in the results will match the order of the parameters. exchangeinfoitem can take any value from the list that follows:
If no exchangeinfoitem are specified then exchange name and type are displayed.
For example, this command displays the name and type for each exchange of the virtual host named "my-vhost":
Lists hash functions supported by encoding commands.
For example, this command instructs the RabbitMQ broker to list all hash functions supported by encoding commands:
Returns queue details. Queue details of the "/" virtual host are returned if the -p flag is absent. The -p flag can be used to override this default.
Displayed queues can be filtered by their status or location using one of the following mutually exclusive options:
The queueinfoitem parameter is used to indicate which queue information items to include in the results. The column order in the results will match the order of the parameters. queueinfoitem can take any value from the list that follows:
Queues which are located on cluster nodes that are currently down will be shown with a status of "down" (and most other queueinfoitem will be unavailable).
If no queueinfoitem are specified then queue name and depth are displayed.
For example, this command displays the depth and number of consumers for each queue of the virtual host named "my-vhost"
Tests queue leader replicas to respond within the given timeout. Lists those which did not respond in time.
Displayed queues can be filtered by their status or location using one of the following mutually exclusive options:
The queueinfoitem parameter is used to indicate which queue information items to include in the results. The column order in the results will match the order of the parameters. queueinfoitem can take any value from the list that follows:
For example, this command lists only those unresponsive queues whose leader replica is hosted on the target node.
Checks that the node OS process is up, registered with EPMD and CLI tools can authenticate with it
Example:
Generate a server status report containing a concatenation of all server status information for support purposes. The output should be redirected to a file when accompanying a support request.
For example, this command creates a server report which may be attached to a support request email:
Lists schema database tables and their properties
For example, this command lists the table names and their active replicas:
Displays broker status information such as the running applications on the current Erlang node, RabbitMQ and Erlang versions, OS name, memory and file descriptor statistics. (See the cluster_status command to find out which nodes are clustered and running.)
For example, this command displays information about the RabbitMQ broker:
Certain features of RabbitMQ (such as the Federation plugin) are controlled by dynamic, cluster-wide parameters. There are 2 kinds of parameters: parameters scoped to a virtual host and global parameters. Each vhost-scoped parameter consists of a component name, a name and a value. The component name and name are strings, and the value is a valid JSON document. A global parameter consists of a name and value. The name is a string and the value is an arbitrary Erlang data structure. Parameters can be set, cleared and listed. In general you should refer to the documentation for the feature in question to see how to set parameters.
Policies is a feature built on top of runtime parameters. Policies are used to control and modify the behaviour of queues and exchanges on a cluster-wide basis. Policies apply within a given vhost, and consist of a name, pattern, definition and an optional priority. Policies can be set, cleared and listed.
Clears a global runtime parameter. This is similar to clear_parameter but the key-value pair isn't tied to a virtual host.
For example, this command clears the global runtime parameter "mqtt_default_vhosts":
Clears a parameter.
For example, this command clears the parameter "node01" for the "federation-upstream" component in the default virtual host:
Lists all global runtime parameters. This is similar to list_parameters but the global runtime parameters are not tied to any virtual host.
For example, this command lists all global parameters:
Lists all parameters for a virtual host.
For example, this command lists all parameters in the default virtual host:
Sets a global runtime parameter. This is similar to set_parameter but the key-value pair isn't tied to a virtual host.
For example, this command sets the global runtime parameter "mqtt_default_vhosts" to the JSON document {"O=client,CN=guest":"/"}:
Sets a parameter.
For example, this command sets the parameter "node01" for the "federation-upstream" component in the default virtual host to the following JSON "guest":
Lists all policies for a virtual host.
For example, this command lists all policies in the default virtual host:
Sets an operator policy that overrides a subset of arguments in user policies. Arguments are identical to those of set_policy.
Supported arguments are:
Sets a policy.
For example, this command sets the policy "federate-me" in the default virtual host so that built-in exchanges are federated:
Clears a policy.
For example, this command clears the "federate-me" policy in the default virtual host:
Clears an operator policy. Arguments are identical to those of clear_policy.
Lists operator policy overrides for a virtual host. Arguments are identical to those of list_policies.
Note that rabbitmqctl manages the RabbitMQ internal user database. Permissions for users from any alternative authorisation backend will not be visible to rabbitmqctl.
Creates a virtual host.
For example, this command instructs the RabbitMQ broker to create a new virtual host called "project9_dev_18":
Clears virtual host limits.
For example, this command clears vhost limits in vhost "qa_env":
Deletes a virtual host.
Deleting a virtual host deletes all its exchanges, queues, bindings, user permissions, parameters and policies.
For example, this command instructs the RabbitMQ broker to delete the virtual host called "test":
Displays configured virtual host limits.
Restarts a failed vhost data stores and queues.
For example, this command instructs the RabbitMQ broker to restart a virtual host called "test":
Sets virtual host limits.
Recognised limits are:
Use a negative value to specify "no limit".
For example, this command limits the max number of concurrent connections in vhost "qa_env" to 64:
This command limits the max number of queues in vhost "qa_env" to 256:
This command clears the max number of connections limit in vhost "qa_env":
This command disables client connections in vhost "qa_env":
Sets user limits.
Recognised limits are:
Use a negative value to specify "no limit".
For example, this command limits the max number of concurrent connections a user is allowed to open "limited_user" to 64:
This command limits the max number of channels a user is allowed to open on a connection "limited_user" to 16:
This command clears the max number of connections limit for user "limited_user":
This command disables client connections for user "limited_user":
Clears user limits.
Recognised limits are:
For example, this command clears max connection limits of user "limited_user":
This command clears all limits of user "limited_user":
Stops tracing.
Starts tracing. Note that the trace state is not persistent; it will revert to being off if the node is restarted.
For example:
For example:
For example:
For example:
Sets the cluster name to name. The cluster name is announced to clients on connection, and used by the federation and shovel plugins to record where a message has been. The cluster name is by default derived from the hostname of the first node in the cluster, but can be changed.
For example, this sets the cluster name to "london":
Sets log level in the running node
Supported log_level values are:
Example:
Enables a feature flag on the target node.
Example:
You can also enable all feature flags by specifying "all":
Lists feature flags
Supported column values are:
Example:
Instructs the broker to close all connections for the specified vhost or entire RabbitMQ node.
For example, this command instructs the RabbitMQ broker to close 10 connections on "qa_env" vhost, passing the explanation "Please close":
This command instructs broker to close all connections to the node:
Instructs the broker to close the connection associated with the Erlang process id connectionpid (see also the list_connections command), passing the explanation string to the connected client as part of the AMQP connection shutdown protocol.
For example, this command instructs the RabbitMQ broker to close the connection associated with the Erlang process id "<rabbit@tanto.4262.0>", passing the explanation "go away" to the connected client:
Evaluates an Erlang expression on the target node
Deletes a queue.
Purges a queue (removes all messages in it).
RabbitMQ plugins can extend rabbitmqctl tool to add new commands when enabled. Currently available commands can be found in rabbitmqctl help output. Following commands are added by RabbitMQ plugins, available in default distribution:
rabbitmq-diagnostics(8), rabbitmq-plugins(8), rabbitmq-server(8), rabbitmq-queues(8), rabbitmq-streams(8), rabbitmq-upgrade(8), rabbitmq-service(8), rabbitmq-env.conf(5), rabbitmq-echopid(8)
The RabbitMQ Team <info@rabbitmq.com>
If you have questions about the contents of this guide or any other topic related to RabbitMQ, don't hesitate to ask them on the RabbitMQ mailing list.
If you'd like to contribute an improvement to the site, its source is available on GitHub. Simply fork the repository and submit a pull request. Thank you!