pixel

How to install RabbitMQ on Rocky Linux 9

Share on Social Media

Learn step-by-step instructions to install RabbitMQ on Rocky Linux 9 with our comprehensive guide. Set up RabbitMQ effortlessly and optimize your messaging infrastructure today! #centlinux #linux #rabbitmq



What is RabbitMQ?

RabbitMQ is an open-source message broker software that enables applications to communicate and transfer data between each other. It implements the Advanced Message Queuing Protocol (AMQP), which is a widely adopted standard for reliable messaging between different software systems.

At its core, RabbitMQ acts as a mediator or intermediary between two or more applications. It receives messages from a sender, known as a producer, and delivers those messages to a receiver, known as a consumer. The messages are typically organized into queues within RabbitMQ, which provides a way to store and route them.

RabbitMQ supports various messaging patterns, including point-to-point, publish/subscribe, and request/reply. It provides features like message durability, acknowledgments, and routing flexibility, making it a robust and reliable messaging system.

Developers can use RabbitMQ to build distributed and scalable applications that need to handle high volumes of messages and ensure reliable delivery. It is widely used in various industries and scenarios, such as enterprise systems, microservices architectures, event-driven systems, and cloud computing environments.

RabbitMQ is written in Erlang and is known for its stability, performance, and fault-tolerant design. It offers client libraries for multiple programming languages, making it accessible for developers using different technology stacks.

Read Also: How to install RabbitMQ Server on CentOS 8

How to install RabbitMQ on Rocky Linux 9
How to install RabbitMQ on Rocky Linux 9

What is RabbitMQ used for?

RabbitMQ is a powerful message broker software that facilitates communication between different applications or services within a distributed system. It acts as a middleman, receiving messages from one application and routing them to another.

Here are some common use cases for RabbitMQ:

  1. Decoupling: RabbitMQ enables decoupling of various components in a system, allowing them to operate independently. This promotes scalability and flexibility in the architecture.
  2. Asynchronous Messaging: It’s often used for asynchronous communication, where a sender doesn’t need an immediate response from the receiver. This is particularly useful in scenarios where processing time varies or when the sender and receiver are not always available simultaneously.
  3. Load Balancing: RabbitMQ can distribute tasks or messages across multiple workers or consumers, balancing the workload efficiently.
  4. Event-Driven Architecture: It’s frequently employed in event-driven architectures, where components react to events triggered by other components. RabbitMQ facilitates the broadcasting of events to interested parties.
  5. Workflow Management: RabbitMQ can be integrated into workflow management systems, ensuring reliable message delivery and processing in complex business processes.
  6. Integration: It’s widely used for integrating disparate systems and applications, allowing them to communicate seamlessly regardless of the underlying technology stack.

Overall, RabbitMQ serves as a reliable, scalable, and flexible messaging solution for various distributed systems and architectures.


RabbitMQ vs Kafka

Here’s a comparison between RabbitMQ and Kafka presented in a table format:

FeatureRabbitMQKafka
Messaging ModelFollows traditional message queue modelDesigned as a distributed streaming platform
Use CasesTraditional messaging scenarios, task distribution, job queues, integrating systemsReal-time event processing, log aggregation, stream processing, event sourcing, data pipeline architectures
ScalabilityVertical scaling by adding resources to a single node, supports clustering for horizontal scalabilityDesigned for horizontal scalability by adding more broker nodes
DurabilityProvides message durability by persisting messages to diskHighly durable by persisting messages to disk and replicating across broker nodes
Message RetentionRetains messages until consumed or expire based on configurable policiesRetains messages for a configurable retention period, allowing replay within that window

This table provides a concise comparison of key features between RabbitMQ and Kafka, making it easier to understand their differences at a glance.


Environment Specification

We are using a minimal Rocky Linux 9 virtual machine with following specifications.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 4 GB
  • Storage – 40 GB
  • Operating System – Rocky Linux release 9.2 (Blue Onyx)
  • Hostname – rabbitmq-01.centlinux.com
  • IP Address – 192.168.18.87/24

If you’re setting up a virtual lab to practice RabbitMQ installation on Rocky Linux 9, you’ll need reliable hardware or a stable cloud server. For a local home lab, a powerful Mini PC from Amazon is a cost-effective choice to run multiple Linux VMs without performance bottlenecks. [Buy our recommended Mini PC from Amazon]

If you prefer a cloud-based setup, a Hostinger VPS provides an affordable and scalable environment to experiment with RabbitMQ, DevOps tools, and containerized applications. Both options ensure you can follow this guide smoothly while gaining real-world system administration experience. [Get a Hostinger VPS at Discounted Price Now!]

Disclaimer: Some of the links above are affiliate links, meaning I may earn a small commission at no extra cost to you. This helps support the blog and keeps the tutorials free.


Prepare your Rocky Linux Server

Login to your Linux server as root user by using a ssh client.

Set a Fully Qualified Domain Name (FQDN) of your Linux machine and set up Local DNS Resolution by executing following commands.

hostnamectl set-hostname rabbitmq-01.centlinux.com
echo "192.168.18.87 rabbitmq-01 rabbitmq-01.centlinux.com" >> /etc/hosts

Update software packages in your Linux OS by executing dnf command.

dnf update -y

If above command installs a new version of Linux Kernel, then you should reboot your Linux OS with new Kernel before installing RabbitMQ software.

reboot

After reboot, note down the Linux OS and Linux Kernel versions.

cat /etc/rocky-release
uname -r

Output:

Rocky Linux release 9.2 (Blue Onyx)
5.14.0-284.11.1.el9_2.x86_64

Install Additional Yum Repositories

To install RabbitMQ on Linux, you may need some software packages from Extra Packages for Enterprise Linux (EPEL) yum repository. Therefore, install EPEL yum repository as follows.

dnf install -y epel-release

You can download RabbitMQ software from their offical website. Or you can install RabbitMQ official yum repository then install Message Broker software by using Linux Package Manager.

We suggest that you should install RabbitMQ on Linux from their official yum repository.

To install RabbitMQ official yum repository, execute following command at Linux terminal.

curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash

Similarly, you should also install RabbitMQ ErLang repository.

curl -1sLf 'https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/setup.rpm.sh' | sudo -E bash

Build yum cache for newly installed yum repositories.

dnf makecache

Install RabbitMQ on Rocky Linux 9

All required yum repositories have been added. Now you can install RabbitMQ on Linux by using dnf command.

dnf install -y rabbitmq-server

Enable and start RabbitMQ service.

systemctl enable --now rabbitmq-server.service

Install RabbitMQ Plugins

To enable web based Management Console for your Message Broker Software, you need to install RabbitMQ plugins on your Linux Server.

rabbitmq-plugins enable rabbitmq_management

Output:

Enabling plugins on node rabbit@rabbitmq-01:
rabbitmq_management
The following plugins have been configured:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to rabbit@rabbitmq-01...
The following plugins have been enabled:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch

started 3 plugins.

Configure Linux Firewall

Identify the service ports, that are being used by RabbitMQ software, execute following commands on Linux terminal.

ss -tulpn | grep beam
ss -tulpn | grep epmd

Output:

tcp   LISTEN 0      1024                             0.0.0.0:15672      0.0.0.0:*    users:(("beam.smp",pid=2172,fd=37))
tcp LISTEN 0 128 0.0.0.0:25672 0.0.0.0:* users:(("beam.smp",pid=2172,fd=18))
tcp LISTEN 0 128 *:5672 *:* users:(("beam.smp",pid=2172,fd=35))

tcp LISTEN 0 4096 0.0.0.0:4369 0.0.0.0:* users:(("epmd",pid=2208,fd=3))
tcp LISTEN 0 4096 [::]:4369 [::]:* users:(("epmd",pid=2208,fd=4))

Allow above service ports in Linux firewall.

firewall-cmd --permanent --add-port={4369,5672,15672,25672}/tcp
firewall-cmd --reload

Install rabbitmqadmin on Rocky Linux 9

The management plugin ships with a command line tool rabbitmqadmin which can perform some of the same actions as the Web-based UI, and which may be more convenient for automation tasks.

rabbitmqadmin can be downloaded from any RabbitMQ node that has the management plugin enabled. Navigate to http://{hostname}:15672/cli/rabbitmqadmin to download it. The tool requires a supported version of Python to be installed.

You can use following curl command to download rabbitmqadmin.

curl http://localhost:15672/cli/rabbitmqadmin -o /usr/local/bin/rabbitmqadmin

Grant execute permissions to rabbitmqadmin command.

chmod +x /usr/local/bin/rabbitmqadmin

Create a RabbitMQ Admin User

RabbitMQ software shipped with a default user guest with password guest. This guest user has administrative privileges but it can only be login to message-broker server from localhost.

Therefore, you need to create another admin user to access RabbitMQ server web interface remotely.

First, check the already available users on Message Broker server.

rabbitmqctl list_users

Output:

Listing users ...
user tags
guest [administrator]

Execute following command at Linux terminal to create a new RabbitMQ user.

rabbitmqctl add_user admin P@ssw0rd

Output:

Adding user "admin" ...
Done. Don't forget to grant the user permissions to some virtual hosts! See 'rabbitmqctl help set_permissions' to learn more.

Set [administrator] tag for admin user to make it a RabbitMQ Administrator.

rabbitmqctl set_user_tags admin administrator

Output:

Setting tags for user "admin" to [administrator] ...

Check the list of available users again.

rabbitmqctl list_users

Output:

Listing users ...
user tags
admin [administrator]
guest [administrator]

Create a RabbitMQ Virtual Host

RabbitMQ is multi-tenant system: connections, exchanges, queues, bindings, user permissions, policies and some other things belong to virtual hosts, logical groups of entities. If you are familiar with virtual hosts in Apache or server blocks in Nginx, the idea is similar. There is, however, one important difference: virtual hosts in Apache are defined in the configuration file; that’s not the case with RabbitMQ: virtual hosts are created and deleted using rabbitmqctl or HTTP API instead.

To create a RabbitMQ virtual host, you can use following Linux command.

rabbitmqctl add_vhost /my_vhost

Output:

Adding vhost "/my_vhost" ...

Check the available virtual host on your Message Broker server.

rabbitmqctl list_vhosts

Output:

Listing vhosts ...
name
/my_vhost
/

Grant permissions on my_vhost to admin user.

rabbitmqctl set_permissions -p /my_vhost admin ".*" ".*" ".*"

Output:

Setting permissions for user "admin" in vhost "/my_vhost" ...

Check the permissions of admin user.

rabbitmqctl list_user_permissions admin

Output:

Listing permissions for user "admin" ...
vhost configure write read
/my_vhost .* .* .*

Check the permission on my_vhost.

rabbitmqctl list_permissions -p /my_vhost

Output:

Listing permissions for vhost "/my_vhost" ...
user configure write read
admin .* .* .*

Create a Message Queue

You can create a message queue by using rabbitmqadmin command.

rabbitmqadmin -V /my_vhost -u admin -p P@ssw0rd declare queue

Output:

name=my_queue01
queue declared

Send a message to your message queue by using following command.

rabbitmqadmin -V /my_vhost -u admin -p P@ssw0rd publish

Output:

routing_key=my_queue01 payload='Hello World!' exchange=amq.default
Message published

Receive the message in your message queue.

rabbitmqadmin -V /my_vhost -u admin -p P@ssw0rd get queue=my_queue01

Output:

+-------------+----------+---------------+--------------+---------------+------------------+------------+-------------+
| routing_key | exchange | message_count | payload | payload_bytes | payload_encoding | properties | redelivered |
+-------------+----------+---------------+--------------+---------------+------------------+------------+-------------+
| my_queue01 | | 0 | Hello World! | 12 | string | | False |
+-------------+----------+---------------+--------------+---------------+------------------+------------+-------------+

Access RabbitMQ Server Web Interface

Open URL http://rabbitmq-01.centlinux.com:15672 in a web browser.

RabbitMQ Server Login
RabbitMQ Server Login

Login as admin user.

RabbitMQ Dashboard
RabbitMQ Dashboard

After successful login, you may reach at the dashboard of RabbitMQ Management web interface. You can perform complete administration of your message-broker server from here.

Click on “Queues”.

RabbitMQ Queues
RabbitMQ Queues

Video Tutorial

YouTube player

Final Thoughts

When delving into the realm of RabbitMQ installation on Rocky Linux 9, meticulous guidance is key. By following our detailed instructions, you’ll seamlessly integrate RabbitMQ into your system, ensuring a robust messaging infrastructure. Let’s embark on this journey together, simplifying the installation process and empowering your system’s capabilities.

Your Linux servers deserve expert care! I provide reliable management and optimization services tailored to your needs. Discover how I can help!


FAQs

Q1: Can I install RabbitMQ without Erlang on Rocky Linux 9?
No, Erlang is a prerequisite because RabbitMQ is built on it. You must install Erlang first for RabbitMQ to work.

Q2: How do I ensure RabbitMQ starts automatically after a reboot?
Use the command sudo systemctl enable rabbitmq-server to enable auto-start on boot.

Q3: Is there a way to change the RabbitMQ default ports during installation?
Ports can’t be changed during installation but can be modified later in the RabbitMQ configuration files.

Q4: What user permissions are required to run RabbitMQ on Rocky Linux 9?
RabbitMQ runs under its own user (rabbitmq). Ensure you have sudo privileges to install and manage the service.

Q5: How can I verify that RabbitMQ is communicating properly after installation?
Use sudo rabbitmqctl status to check its status, and test communication by sending/receiving a message via a client tool or script.


What’s Next

If you want to truly master modern distributed systems, RabbitMQ and Messaging Concepts by Mustafa Kök is the perfect online course to get you started. This course breaks down complex messaging patterns into easy-to-understand lessons, helping you gain the practical skills needed to design scalable, fault-tolerant applications.

Whether you’re a developer, DevOps engineer, or system architect, this training equips you with real-world knowledge that you can immediately apply in your projects. Don’t miss out on enhancing your career opportunities with this in-demand skill. (Disclaimer: This post contains affiliate links. If you purchase the course through these links, I may earn a small commission at no extra cost to you. This helps support my blog and allows me to continue creating valuable content.)


Looking for something?

Leave a Reply

Available for Amazon Prime