RabbitMQ is a free and open-source message broker written in Erlang programming language. RabbitMQ can be used in implementing the Advanced Message Queuing Protocol (AMQP) on modern operating systems because it is a message oriented middle-ware. This article demonstrates how to install and configure RabbitMQ on Rocky Linux 8 server.
RabbitMQ has many features, among them are:
- Flexible routing since it has several in-built exchange types for typical routing.
- It is reliable as it offers a variety of features.
- It offers clustering as several RabbitMQ servers can be clustered to one local broker.
- It has many clients for almost every language.
- Supports messaging over multi protocols.
- Has a management UI that makes it easy to monitor aspects of your message broker.
- Offers commercial support, training and consulting from Pivotal.
- Offers tracing in cases when your broker is misbehaving.
- It has a large community around the world producing all kinds of clients, guides, plugins and many others.
For RabbitMQ installation, we need the following:
- Rocky Linux 8
- User with sudo privileges
- EPEL repository
- RabbitMQ and Erlang repositories
Step 1: Set RabbitMQ Server Hostname
You can begin by configuring your hostname in Rocky Linux 8.
export HOSTNAME="rabbitmq.techviewleo.com" sudo hostnamectl set-hostname $HOSTNAME
Replace rabbitmq.techviewleo.com with your actual hostname.
Confirm the set hostname with:
Step 2: Configure required Add Repositories
Adding repositories is preferred to using rpm files when installing RabbitMQ because rpm packages come with dependency issues and you have to update packages manually.
Add EPEL repository
Add Epel repository to Rocky Linux 8 system using:
sudo yum -y install epel-release
Add Erlang and RabbitMQ repositories
Add the RabbitMQ and Erlang repositories to /etc/yum.repos.d directory.
Add RabbitMQ repository to Rocky Linux 8 system:
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash
Add Erlang repository to Rocky Linux 8 system:
curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash
After adding the repositories, we now update our system.
sudo yum -y update
Step 3: Install RabbitMQ on Rocky Linux 8
After adding the required repositories, we now install Erlang and RabbitMQ-server on Rocky Linux 8. It is always important to check for the latest release of RabbitMQ from the official release page before installation. Also check for the latest version of Erlang on the official release page.
After adding the repository, download Erlang with this command.
sudo yum -y install erlang
Check the version of Erlang installed using
$ erl Erlang/OTP 24 [erts-12.0.3] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] Eshell V12.0.3 (abort with ^G)
Abort Eshell using ^G
1> User switch command --> q
With Erlang successfully installed, we proceed to RabbitMQ-server installation.
sudo yum -y install rabbitmq-server
Step 4: Configuring RabbitMQ on Rocky Linux 8
After installing RabbitMQ-server successfully. We start and enable rabbitmq-server to run on boot.
sudo systemctl start rabbitmq-server.service sudo systemctl enable rabbitmq-server.service
Confirm that the service status is running:
$ systemctl status rabbitmq-server.service ● rabbitmq-server.service - RabbitMQ broker Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2021-07-04 20:26:53 UTC; 11s ago Main PID: 15928 (beam.smp) Status: "Initialized" Tasks: 22 (limit: 11224) Memory: 79.9M CGroup: /system.slice/rabbitmq-server.service ├─15928 /usr/lib64/erlang/erts-12.0.3/bin/beam.smp -W w -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 5000000 -stbt > ├─15943 erl_child_setup 32768 ├─15967 /usr/lib64/erlang/erts-12.0.3/bin/epmd -daemon ├─15983 inet_gethost 4 └─15984 inet_gethost 4 Jul 04 20:26:48 rabbitmq.techviewleo.com rabbitmq-server: TLS Library: OpenSSL - OpenSSL 1.1.1g FIPS 21 Apr 2020 Jul 04 20:26:48 rabbitmq.techviewleo.com rabbitmq-server: Doc guides: https://rabbitmq.com/documentation.html Jul 04 20:26:48 rabbitmq.techviewleo.com rabbitmq-server: Support: https://rabbitmq.com/contact.html Jul 04 20:26:48 rabbitmq.techviewleo.com rabbitmq-server: Tutorials: https://rabbitmq.com/getstarted.html Jul 04 20:26:48 rabbitmq.techviewleo.com rabbitmq-server: Monitoring: https://rabbitmq.com/monitoring.html Jul 04 20:26:48 rabbitmq.techviewleo.com rabbitmq-server: Logs: /var/log/rabbitmq/[email protected] Jul 04 20:26:48 rabbitmq.techviewleo.com rabbitmq-server: /var/log/rabbitmq/[email protected]_upgrade.log Jul 04 20:26:48 rabbitmq.techviewleo.com rabbitmq-server: Config file(s): (none) Jul 04 20:26:53 rabbitmq.techviewleo.com rabbitmq-server: Starting broker... completed with 0 plugins. Jul 04 20:26:53 rabbitmq.techviewleo.com systemd: Started RabbitMQ broker.
By default, RabbitMQ has a guest user who can connect from localhost. To be able to use RabbitMQ, we need to add a user. In this case, the added user is “admin“
$ sudo rabbitmqctl add_user admin Adding user "admin" ... Password:
You are required to set a password for the created user. Then we assign permissions to the user.
$ sudo rabbitmqctl set_user_tags admin administrator $ sudo rabbitmqctl list_users Listing users ... user tags admin [administrator] guest [administrator]
Other RabbitMQ useful commands are:
Change the password of a user:
$ sudo rabbitmqctl change_password admin strongpassword Changing password for user "admin" ...
$ sudo rabbitmqctl add_vhost /new_vhost Adding vhost "/new_vhost" ...
$ sudo rabbitmqctl list_vhosts Listing vhosts ... name / /new_vhost
Grant user permissions for Virtualhost:
$ sudo rabbitmqctl set_permissions -p /new_vhost admin ".*" ".*" ".*" Setting permissions for user "admin" in vhost "/new_vhost" ...
List user permissions:
$ sudo rabbitmqctl list_user_permissions admin Listing permissions for user "admin" ... vhost configure write read /new_vhost .* .* .*
List vhost permissions:
$ sudo rabbitmqctl list_permissions -p /new_vhost isting permissions for vhost "/new_vhost" ... user configure write read admin .* .* .*
Delete user permissions:
$ sudo rabbitmqctl clear_permissions -p /new_vhost admin Clearing permissions for user "admin" in vhost "/new_vhost" ...
$ sudo rabbitmqctl delete_vhost /new_vhost Deleting vhost "/new_vhost" ...
$ sudo rabbitmqctl delete_user admin Deleting user "admin" ...
Step 5: Enable RabbitMQ User Interface In Rocky Linux 8.
It is possible to enable the management plugin to use a Web UI to administer RabbitMQ by running the following commands in Rocky Linux 8:
sudo rabbitmq-plugins enable rabbitmq_management sudo systemctl restart rabbitmq-server
In order to allow access management console remotely, you allow traffic on the following ports, 4369, 25672, 15672, 61613, 61614, 1883, 8883, 5672 and 5671 as below.
sudo firewall-cmd --zone=public --permanent --add-port=4369/tcp --add-port=25672/tcp --add-port=5671-5672/tcp --add-port=15672/tcp --add-port=61613-61614/tcp --add-port=1883/tcp --add-port=8883/tcp sudo firewall-cmd --reload
You can check the status of RabbitMQ using:
$ sudo rabbitmqctl status Interface: [::], port: 15672, protocol: http, purpose: HTTP API Interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication Interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
Then you can acess the http://server:15672/ from a client. You will see a login window as below:
While here, login with the user you created.
Using the Web UI, you can easily execute tasks such as adding users, adding vhosts,creating queues e.t.c
In the above article, I have demonstrated how to install and configure RabbitMQ on Rocky Linux 8. I have also demonstrated how the basic commands of RabbitMQ work. I believe this article was helpful.
Find more articles on our website.