RabbitMQ


This is the RabbitMQ Server Administrator's Guide. (Note: it is still under development. Please contact us if you have any suggestions or wished-for features!)

Building and installation

Please see the build and installation guides for instructions on compiling, installing, starting and shutting down the server.

Default database contents

When the server first starts running, and detects that its database is uninitialised or has been deleted, it initialises a fresh database with the following resources:

  • a virtual host named /
  • realms /data and /admin within the / virtual host
  • a user named guest with a default password of guest, granted full access to all realms within the / virtual host. See here for password-changing instructions.

Management overview

rabbitmqctl is a command line tool for managing a RabbitMQ broker. It performs all actions by connecting to one of the broker's node. By default that is the node named "rabbit" on the local host. This can be overridden by explicitly specifying the node name before the command using the "-n" flag, e.g.

rabbitmqctl -n rabbit@shortstop add_user tonyg changeit

This command instructs the RabbitMQ broker at the Erlang node rabbit@shortstop to create a user named tonyg with (initial) password changeit.

On a host named "server.example.com", the node name of the RabbitMQ Erlang node will usually be rabbit@server (unless NODENAME has been set to some non-default value at broker startup time). The output of hostname -s is usually the correct suffix to use after the "@" sign.

Application and cluster management

Stopping the RabbitMQ node

rabbitmqctl stop

Stops the Erlang node on which RabbitMQ is running. To restart the node follow the instructions for Running the Server in the installation guide.

For example:

rabbitmqctl stop

This command instructs the RabbitMQ node to terminate.

Stopping the RabbitMQ application

rabbitmqctl stop_app

Stops the RabbitMQ application, leaving the Erlang node 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:

rabbitmqctl stop_app

This command instructs the RabbitMQ node to stop the RabbitMQ application.

Starting the RabbitMQ application

rabbitmqctl start_app

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:

rabbitmqctl start_app

This command instructs the RabbitMQ node to start the RabbitMQ application.

Displaying the RabbitMQ broker status

rabbitmqctl status

Displays various information about the RabbitMQ broker, such as whether the RabbitMQ application on the current node, its version number, what nodes are part of the broker, which of these are running.

For example:

rabbitmqctl status

This command displays information about the RabbitMQ broker.

Resetting a RabbitMQ node

rabbitmqctl reset
rabbitmqctl force_reset

Return 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, vhosts and realms, and deletes all persistent messages.

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:

rabbitmqctl reset

This command resets the RabbitMQ node.

Cluster management

rabbitmqctl cluster clusternode ...
clusternode
Subset of the nodes of the cluster to which this node should be connected.

Instruct the node to become member of a cluster with the specified nodes.

Cluster nodes can be of two types: disk or ram. Disk nodes replicate data in ram and on disk, 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 and are mainly used for scalability. A cluster must always have at least one disk node.

If the current node is to become a disk node it needs to appear in the cluster node list. Otherwise it becomes a ram node. If the node list is empty or only contains the current node then the node becomes a standalone, i.e. non-clustered, (disk) node.

After executing the cluster command, whenever the RabbitMQ application is started on the current node it will attempt to connect to the specified nodes, thus becoming an active node in the cluster comprising those nodes (and possibly others).

The list of nodes does not have to contain all the cluster's nodes; a subset is sufficient. Also, clustering generally succeeds as long as at least one of the specified nodes is active. Hence adjustments to the list are only necessary if the cluster configuration is to be altered radically.

For this command to succeed the RabbitMQ application must have been stopped, e.g. with stop_app. Furthermore, turning a standalone node into a clustered node requires the node be reset first, in order to avoid accidental destruction of data with the cluster command.

For more details see the clustering guide.

Example:

rabbitmqctl cluster rabbit@tanto hare@elena

This command instructs the RabbitMQ node to join the cluster with nodes rabbit@tanto and hare@elena. If the node is one of these then it becomes a disk node, otherwise a ram node.

User management

Creating a user

rabbitmqctl add_user username password
username
The name of the user to create.
password
The password the created user will use to log in to the broker.

For example:

rabbitmqctl add_user tonyg changeit

This command instructs the RabbitMQ broker to create a user named tonyg with (initial) password changeit.

Deleting a user

rabbitmqctl delete_user username
username
The name of the user to delete.

For example:

rabbitmqctl delete_user tonyg

This command instructs the RabbitMQ broker to delete the user named tonyg.

Changing a user's password

rabbitmqctl change_password username newpassword
username
The name of the user whose password is to be changed.
newpassword
The new password for the user.

For example:

rabbitmqctl change_password tonyg newpass

This command instructs the RabbitMQ broker to change the password for the user named tonyg to newpass.

Listing users

rabbitmqctl list_users

For example:

rabbitmqctl list_users

This command instructs the RabbitMQ broker to list all users.

Access control

Creating a virtual host

rabbitmqctl add_vhost vhostpath
vhostpath
The name of the virtual host entry to create.

Note that the virtual host is created with the two default realms, /data and /admin.

For example:

rabbitmqctl add_vhost test

This command instructs the RabbitMQ broker to create a new virtual host called test, with the default /data and /admin realms, and with no users allowed access to the virtual host or its realms.

Deleting a virtual host

rabbitmqctl delete_vhost vhostpath
vhostpath
The name of the virtual host entry to delete.

Deleting a virtual host deletes all its exchanges, queues, user mappings, realms and associated permissions.

For example:

rabbitmqctl delete_vhost test

This command instructs the RabbitMQ broker to delete the virtual host called test.

Listing virtual hosts

rabbitmqctl list_vhosts

For example:

rabbitmqctl list_vhosts

This command instructs the RabbitMQ broker to list all virtual hosts.

Granting access to a virtual host

rabbitmqctl map_user_vhost username vhostpath
username
The name of the user to grant access to the specified virtual host.
vhostpath
The name of the virtual host to grant access to.

For example:

rabbitmqctl map_user_vhost tonyg test

This command instructs the RabbitMQ broker to grant the user named tonyg access to the virtual host called test.

Denying access to a virtual host

rabbitmqctl unmap_user_vhost username vhostpath
username
The name of the user to deny access to the specified virtual host.
vhostpath
The name of virtual host to deny access to.

Denying a user access to a virtual host also deletes all their permissions for realms of that virtual host.

For example:

rabbitmqctl unmap_user_vhost tonyg test

This command instructs the RabbitMQ broker to deny the user named tonyg access to the virtual host called test, and to remove all their permissions for realms of that virtual host.

Listing virtual hosts accessible to user

rabbitmqctl list_user_vhost username 
username
The name of the user for which to list the virtual hosts that they have been granted access.

For example:

rabbitmqctl list_user_vhosts tonyg

This command instructs the RabbitMQ broker to list all the virtual hosts to which the user named tonyg has been granted access.

Listing users with access to a virtual host

rabbitmqctl list_vhost_users vhostpath
vhostpath
The name of the virtual host for which to list the users that have been granted access to it.

For example:

rabbitmqctl list_vhosts_user test

This command instructs the RabbitMQ broker to list all the users which have been granted access to the virtual host called test.

Creating a realm

rabbitmqctl add_realm vhostpath realm
vhostpath
The name of the virtual host in which to create the realm.
realm
The name of the realm (i.e. /data, /admin etc.) to create.

For example:

rabbitmqctl add_realm test /data/test

This command instructs the RabbitMQ broker to create a new realm named /data/test in the virtual host called test.

Deleting a realm

rabbitmqctl delete_realm vhostpath realm
vhostpath
The name of the virtual host in which to delete the realm.
realm
The name of the realm (i.e. /data, /admin etc.) to delete.

Deleting a realm deletes all associated user permissions.

For example:

rabbitmqctl delete_realm test /data/test

This command instructs the RabbitMQ broker to delete the realm named /data/test, and its associated user permissions, in the virtual host called test.

Listing realms

rabbitmqctl list_realms vhostpath
vhostpath
The name of the virtual host for which to list the realms.

For example:

rabbitmqctl list_realm test

This command instructs the RabbitMQ broker to list all the realms configured for the virtual host called test.

Setting user permissions

rabbitmqctl set_permissions username vhostpath realm [flag ...]
username
The name of the user whose permissions are being adjusted.
vhostpath
The virtual host containing the realm to allow or disallow access to.
realm
The name of the realm (i.e. /data, /admin etc.) we are to adjust the permissions for.
flag
Zero or more flag definitions - any of passive, active, write, read or all. If no flags are supplied, the server will remove all permissions for the named realm from the named user.

Note that for this command to succeed the username must have been granted access to the virtual host, e.g. by using the map_user_vhost command, and the realm must have been added to the virtual host, e.g. by using the add_realm command.

For example:

rabbitmqctl set_permissions tonyg test /data all

This command instructs the RabbitMQ broker to allow user tonyg full access to the /data realm within the test virtual host.

rabbitmqctl set_permissions tonyg test /data write passive

This command instructs the RabbitMQ broker to permit tonyg to publish messages to exchanges and to assert the existence of previously created exchanges and queues, but not to read from queues or create his own queues or exchanges.

rabbitmqctl set_permissions tonyg test /data

This command instructs the RabbitMQ broker to prevent tonyg from accessing or creating any resource within the /data realm of the test virtual host.

Listing user permissions

rabbitmqctl list_permissions username vhostpath
username
The name of the user whose permissions to show.
vhostpath
The virtual host for which to show the named user's permissions.

For example:

rabbitmqctl list_permissions tonyg test

This command instructs the RabbitMQ broker to list the permissions for the user named tonyg in realms of the virtual host called test.