0
0
RabbitmqHow-ToBeginner ยท 3 min read

How to Use rabbitmqctl: Commands and Examples

Use rabbitmqctl to manage RabbitMQ server from the command line. It lets you check server status, list users, manage queues, and control nodes by running commands like rabbitmqctl status or rabbitmqctl list_queues.
๐Ÿ“

Syntax

The basic syntax of rabbitmqctl is:

  • rabbitmqctl [command] [options]

Here, command is the action you want to perform, such as status, list_queues, or add_user. options are extra details needed for some commands, like usernames or queue names.

bash
rabbitmqctl [command] [options]
๐Ÿ’ป

Example

This example shows how to check the RabbitMQ server status and list all queues with their message counts.

bash
rabbitmqctl status
rabbitmqctl list_queues name messages
Output
Status of node rabbit@hostname ... [{pid,12345}, {running_applications,[{rabbit,"RabbitMQ","3.11.10"}, {os_mon,"CPO CXC 138 46"}, {mnesia,"MNESIA CXC 138 12"}]}, {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]}, {vm_memory_high_watermark,0.4}, {disk_free_limit,50000000}, {disk_free,123456789}] queue1 10 queue2 0 queue3 5
โš ๏ธ

Common Pitfalls

Common mistakes when using rabbitmqctl include:

  • Running commands without proper permissions or as a non-root user, causing permission errors.
  • Using rabbitmqctl on a remote server without SSH or proper access.
  • Confusing rabbitmqctl commands with rabbitmqadmin, which is a different tool.
  • Not specifying the correct node name if multiple RabbitMQ nodes run on the same machine.

Always run rabbitmqctl on the server where RabbitMQ is installed and with sufficient privileges.

bash
## Wrong: Running without sudo (may fail)
rabbitmqctl status

## Right: Running with sudo
sudo rabbitmqctl status
๐Ÿ“Š

Quick Reference

CommandDescription
rabbitmqctl statusShows RabbitMQ server status and node info
rabbitmqctl list_queuesLists all queues with details like message count
rabbitmqctl add_user Creates a new RabbitMQ user
rabbitmqctl delete_user Deletes an existing user
rabbitmqctl set_permissions -p ".*" ".*" ".*"Sets user permissions on a virtual host
rabbitmqctl stopStops the RabbitMQ server node
rabbitmqctl resetResets the node (clears data, use with caution)
โœ…

Key Takeaways

Use rabbitmqctl commands on the RabbitMQ server with proper permissions.
Common commands include status, list_queues, and user management commands.
Always run rabbitmqctl with sudo if permission errors occur.
Do not confuse rabbitmqctl with rabbitmqadmin, they serve different purposes.
Check the node name if managing multiple RabbitMQ nodes on the same machine.