How to Install RabbitMQ on AlmaLinux 9

By Raman Kumar

Updated on Sep 17, 2024

In this tutorial, we'll guide you to install RabbitMQ on AlmaLinux 9 server.

RabbitMQ is an open-source message broker widely used for handling messaging between distributed systems. It supports multiple messaging protocols, including the Advanced Message Queuing Protocol (AMQP), making it a powerful tool for managing communication between microservices, event-driven architectures, and other distributed applications. RabbitMQ allows asynchronous message passing, enabling systems to decouple services and scale efficiently.

It offers features such as message routing, message acknowledgment, persistence, and high availability, making it suitable for both small projects and large enterprise applications. Its built-in management interface allows for easy monitoring, configuration, and management of queues and exchanges.

Prerequisites

  • An AlmaLinux 9 dedicated server or KVM VPS with root or sudo privileges.
  • A basic understanding of the command line.

Install RabbitMQ on AlmaLinux

Step 1: Update the System

Before installing RabbitMQ, ensure your system is up to date by running the following command:

sudo dnf update -y

This will download and install any available updates for AlmaLinux 9.

Step 2: Install RabbitMQ and Erlang

RabbitMQ depends on Erlang, a language runtime for highly scalable systems. 

The following example sets up a repository that will install RabbitMQ and its Erlang dependency from a Cloudsmith mirror. We have copied following repository from RabbitMQ official documentation

These repository mirrors only provide 64-bit x86 (amd64) packages of Erlang. Create rabbitmq.repo file using following command:

vi /etc/yum.repos.d/rabbitmq.repo

Add following repository:

##
## Zero dependency Erlang RPM
##

[modern-erlang]
name=modern-erlang-el9
# Use a set of mirrors maintained by the RabbitMQ core team.
# The mirrors have significantly higher bandwidth quotas.
baseurl=https://yum1.rabbitmq.com/erlang/el/9/$basearch
        https://yum2.rabbitmq.com/erlang/el/9/$basearch
repo_gpgcheck=1
enabled=1
gpgkey=https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key
gpgcheck=1
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1
type=rpm-md

[modern-erlang-noarch]
name=modern-erlang-el9-noarch
# Use a set of mirrors maintained by the RabbitMQ core team.
# The mirrors have significantly higher bandwidth quotas.
baseurl=https://yum1.rabbitmq.com/erlang/el/9/noarch
        https://yum2.rabbitmq.com/erlang/el/9/noarch
repo_gpgcheck=1
enabled=1
gpgkey=https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key
       https://github.com/rabbitmq/signing-keys/releases/download/3.0/rabbitmq-release-signing-key.asc
gpgcheck=1
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1
type=rpm-md

[modern-erlang-source]
name=modern-erlang-el9-source
# Use a set of mirrors maintained by the RabbitMQ core team.
# The mirrors have significantly higher bandwidth quotas.
baseurl=https://yum1.rabbitmq.com/erlang/el/9/SRPMS
        https://yum2.rabbitmq.com/erlang/el/9/SRPMS
repo_gpgcheck=1
enabled=1
gpgkey=https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key
       https://github.com/rabbitmq/signing-keys/releases/download/3.0/rabbitmq-release-signing-key.asc
gpgcheck=1
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1


##
## RabbitMQ Server
##

[rabbitmq-el9]
name=rabbitmq-el9
baseurl=https://yum2.rabbitmq.com/rabbitmq/el/9/$basearch
        https://yum1.rabbitmq.com/rabbitmq/el/9/$basearch
repo_gpgcheck=1
enabled=1
# Cloudsmith's repository key and RabbitMQ package signing key
gpgkey=https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key
       https://github.com/rabbitmq/signing-keys/releases/download/3.0/rabbitmq-release-signing-key.asc
gpgcheck=1
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1
type=rpm-md

[rabbitmq-el9-noarch]
name=rabbitmq-el9-noarch
baseurl=https://yum2.rabbitmq.com/rabbitmq/el/9/noarch
        https://yum1.rabbitmq.com/rabbitmq/el/9/noarch
repo_gpgcheck=1
enabled=1
# Cloudsmith's repository key and RabbitMQ package signing key
gpgkey=https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key
       https://github.com/rabbitmq/signing-keys/releases/download/3.0/rabbitmq-release-signing-key.asc
gpgcheck=1
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1
type=rpm-md

[rabbitmq-el9-source]
name=rabbitmq-el9-source
baseurl=https://yum2.rabbitmq.com/rabbitmq/el/9/SRPMS
        https://yum1.rabbitmq.com/rabbitmq/el/9/SRPMS
repo_gpgcheck=1
enabled=1
gpgkey=https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key
gpgcheck=0
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1
type=rpm-md

Save and exit the file.

Next install dependencies from the standard repositories:

## install these dependencies from standard OS repositories
dnf install -y socat logrotate

Finally, install modern Erlang and RabbitMQ:

## install RabbitMQ and zero dependency Erlang
dnf install -y erlang rabbitmq-server

Verify the installation:

erl -version

You should see the Erlang version output if the installation was successful.

Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 14.2.5.2

Enable and Start RabbitMQ Service:

Once RabbitMQ is installed, enable it to start at boot and start the RabbitMQ service:

sudo systemctl enable rabbitmq-server
sudo systemctl start rabbitmq-server

Check RabbitMQ Status:

You can check if RabbitMQ is running properly by using the following command:

sudo systemctl status rabbitmq-server

You should see output indicating that RabbitMQ is active and running.

Step 4: Enable RabbitMQ Management Plugin

RabbitMQ comes with a web-based management interface that makes it easier to monitor and manage RabbitMQ. To enable the RabbitMQ management plugin, run the following command:

sudo rabbitmq-plugins enable rabbitmq_management

Once enabled, you can access the RabbitMQ management dashboard at http://<your-server-ip>:15672. The default username and password are both guest, but it’s recommended to create a new admin user for security reasons.

Step 5: Create an Admin User

Create a new user by running the following command:

sudo rabbitmqctl add_user admin your_password

Replace your_password with a strong password.

Set the user as an administrator:

sudo rabbitmqctl set_user_tags admin administrator

Grant permissions to the new admin user:

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

Remove the default guest user if not needed:

sudo rabbitmqctl delete_user guest

Now, you can log in to the RabbitMQ management interface using the username admin and the password you just set.

Step 6: Configure Firewall

If you are running a firewall on your AlmaLinux 9 server, you need to allow RabbitMQ’s default ports through the firewall:

sudo firewall-cmd --permanent --add-port=5672/tcp
sudo firewall-cmd --permanent --add-port=15672/tcp
sudo firewall-cmd --reload
  • Port 5672 is used for RabbitMQ messaging protocol.
  • Port 15672 is used for the RabbitMQ management web interface.

Step 7: Verify RabbitMQ Installation

To ensure everything is working correctly, you can access the management interface by visiting:

http://<your-server-ip>:15672

Login with your newly created admin user credentials. You should now see the RabbitMQ dashboard where you can manage queues, exchanges, and more.

Step 8: Managing RabbitMQ

Here are some basic commands to manage RabbitMQ:

Start RabbitMQ Server:

sudo systemctl start rabbitmq-server

Stop RabbitMQ Server:

sudo systemctl stop rabbitmq-server

Restart RabbitMQ Server:

sudo systemctl restart rabbitmq-server

Check RabbitMQ Status:

sudo systemctl status rabbitmq-server

Conclusion

We have seen how to install RabbitMQ on an AlmaLinux 9 server. You can now use RabbitMQ to handle messaging between your applications. You also have access to the RabbitMQ management interface for monitoring and managing your message queues.

To further secure your RabbitMQ installation, consider restricting access to the management interface and setting up SSL certificates.