Advanced
Searching inInstall guides
How to search
  • Paste an error message in quotes, e.g. "permission denied", to find the fix table that explains it.
  • Choose an area and a part of the guide (install, first settings, daily use, security, fixes) to go straight to the right step.
  • "two words" finds the exact phrase.
  • Plain words find names, texts and examples.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search
Try:

Guide 45RabbitMQ · Data

Install and set up RabbitMQ

RabbitMQ is the most used message broker: apps put messages (jobs, events, orders) into queues, and workers take them out and process them — so a slow or broken part does not stop the rest. This guide installs RabbitMQ on Ubuntu, RHEL and in a container, turns on the management UI, removes the default user, makes a virtual host and users with the right rights, sets memory and disk limits, and shows the daily checks and fixes.

  • 9 Lessons
  • 8 Commands

$ run as a normal user# run as root (or with sudo)

45.1

Know it before you install

Producers send messages to an exchange; bindings route them into queues; consumers read from queues and ack each message when done. A virtual host (vhost) is a separate space with its own exchanges, queues and rights — one per app or team. RabbitMQ runs on Erlang.

ItemValue
Packagerabbitmq-server (needs a matching erlang)
Servicerabbitmq-server.service
Config/etc/rabbitmq/rabbitmq.conf
Data / logs/var/lib/rabbitmq/, /var/log/rabbitmq/
Toolsrabbitmqctl, rabbitmq-diagnostics, rabbitmq-plugins, rabbitmq-queues
Ports5672 (AMQP), 5671 (AMQP over TLS), 15672 (management UI/API), 25672 + 4369 (cluster)

45.2

Install on Ubuntu and Debian

The Ubuntu package is the quickest (a bit older version):

apt-get update
apt-get install -y rabbitmq-server
systemctl enable --now rabbitmq-server
rabbitmq-diagnostics status | head -20

For the newest version, use the Team RabbitMQ repositories (Erlang + RabbitMQ) from the RabbitMQ install page for Debian/Ubuntu.

45.3

Install on RHEL, Rocky and Alma

RHEL has no RabbitMQ package. Add the repository file from the RabbitMQ install page for RPM systems (it provides a matching Erlang and RabbitMQ), then:

dnf -y install erlang rabbitmq-server
systemctl enable --now rabbitmq-server

Or run the official container (any Linux with Docker or Podman), which is the fastest way to start:

docker run -d --name rabbitmq --hostname rabbit1 -p 127.0.0.1:5672:5672 -p 127.0.0.1:15672:15672 -v rabbitmq-data:/var/lib/rabbitmq rabbitmq:4-management

The fixed --hostname matters: RabbitMQ stores data by node name.

45.4

First configuration: UI, users and vhosts

Turn on the management UI, remove the default guest user, and create an admin:

rabbitmq-plugins enable rabbitmq_management
rabbitmqctl add_user admin 'change-me-long-random'
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
rabbitmqctl delete_user guest

One vhost and one user per app, with rights only there:

rabbitmqctl add_vhost shop
rabbitmqctl add_user shop-app 'another-long-password'
rabbitmqctl set_permissions -p shop shop-app "^shop\..*" "^shop\..*" "^shop\..*"
rabbitmqctl list_permissions -p shop

The three patterns are configure, write and read — here the app may only use exchanges and queues whose names start with shop..

Limits and listeners in the config file:

/etc/rabbitmq/rabbitmq.conf
listeners.tcp.default = 5672
management.tcp.port = 15672
management.tcp.ip = 127.0.0.1
vm_memory_high_watermark.relative = 0.6
disk_free_limit.absolute = 2GB
default_queue_type = quorum
log.file.level = info
SettingWhy
management.tcp.ip = 127.0.0.1The UI only through an SSH tunnel or Nginx with HTTPS.
vm_memory_high_watermark.relative = 0.6Above 60 % RAM, RabbitMQ blocks publishers (instead of crashing).
disk_free_limit.absolute = 2GBBelow 2 GB free disk, publishers are blocked — the server does not fill up.
default_queue_type = quorumNew queues are replicated and safe in a cluster (RabbitMQ 3.13+/4).
systemctl restart rabbitmq-server
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.1.0/24" port port="5672" protocol="tcp" accept'
firewall-cmd --reload
ssh -L 15672:127.0.0.1:15672 mq1

Then open http://localhost:15672 and log in as admin.

45.5

Daily use: the commands and the real uses

rabbitmq-diagnostics check_running
rabbitmq-diagnostics alarms
rabbitmqctl list_queues -p shop name type messages messages_unacknowledged consumers
rabbitmqctl list_connections user peer_host state
rabbitmqctl list_consumers -p shop
rabbitmq-diagnostics memory_breakdown
rabbitmqctl purge_queue -p shop shop.emails
rabbitmqctl export_definitions /backup/rabbit-defs-$(date +%F).json

Watch the numbers that matter: messages ready growing = workers too slow or down; unacked growing = workers stuck; consumers = 0 = nobody is reading.

Real uses at work:

  • Background jobs: emails, PDFs, image processing, imports (Celery, Sidekiq-like workers, Spring AMQP).
  • Decoupling services: the order service publishes, billing and shipping consume.
  • Retry and dead-letter queues for messages that fail.

45.6

Make it safe

Security checklist:

  • Delete guest; one user per app; vhosts per app/team; permission patterns as small as possible.
  • Management UI on localhost or behind HTTPS + SSO; ports 5672/15672 never public.
  • TLS (port 5671) when clients are on other networks.
  • Memory and disk limits set; monitor alarms (Prometheus plugin rabbitmq_prometheus, port 15692).
  • Quorum queues (3-node cluster) for important data; export definitions as a backup.
  • Keep RabbitMQ and Erlang updated together (supported pairs only).

45.7

Update and remove

apt-get install --only-upgrade -y rabbitmq-server
dnf -y upgrade erlang rabbitmq-server
systemctl disable --now rabbitmq-server
apt-get purge -y rabbitmq-server

Upgrade one minor/major step at a time as the RabbitMQ upgrade guide says; enable all feature flags before a major upgrade (rabbitmqctl enable_feature_flag all).

45.8

Fix common problems

ProblemCauseFix
Publishers hang, logs say memory resource limit alarm setRAM above the watermark.Consumers must catch up; more RAM; check big queues; rabbitmq-diagnostics memory_breakdown.
disk resource limit alarm setFree disk below the limit.Free disk space; purge or consume old queues.
ACCESS_REFUSED - Login was refusedWrong user/password, or guest from a remote host (only allowed on localhost).Use your own user; check the password and vhost permissions.
NOT_ALLOWED - vhost not foundThe client uses another vhost.Create it, or fix the vhost in the connection URL (amqp://user:pass@host:5672/shop).
Messages pile upWorkers are down or too slow.list_consumers; scale workers; check their logs.
Node does not start after a host name changeRabbitMQ stores data by node name.Keep a fixed host name (--hostname in containers); or reset the node.
Cluster: Authentication failed (rejected by the remote node)Erlang cookies differ.Same /var/lib/rabbitmq/.erlang.cookie on all nodes (mode 400).

45.9

Next steps

1What does it mean when "unacked" messages keep growing?

Workers took the messages but do not finish (ack) them — they are stuck or crashing.

2Why delete the guest user?

It is a known default account; your own named users with small rights are safer.

All commands in this chapter