RabbitMQ is a free and open-source message broker software solution designed for applications that need to support legacy protocols, such as STOMP and MQTT. It is written in Erlang and can be used in implementing AMQP on modern operating systems. RabbitMQ receives messages from publishers and routes them to consumers. It provides your application with a common platform to send and receive messages. Currently, RabbitMQ is used worldwide by both small startups and large organizations.
In this post, we will show you how to install the RabbitMQ server on Rocky Linux 8.
Step 1 – Install Required Repositories
Before starting, you will need to install EPLE, Erlang, and RabbitMQ repositories to your server.
First, install the EPEL repository using the commands given below:
dnf update -y dnf install epel-release curl -y
Next, install the Erlang and RabbitMQ repository with the following command:
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | bash curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | bash
Also Read
How to Install Anaconda Python on Rocky Linux 8
Step 2 – Install Erlang
Next, you will also need to install Erlang on your server. Run the following command to install Erlang:
dnf install erlang -y
Once Erlang is installed, run the following command to verify the Erlang:
erl
You will be connected to the Erlang shell, as shown below:
Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [jit] Eshell V12.2 (abort with ^G) 1>
Press CTRL+C and type a to exit from the Erlang shell.
Step 3 – Install RabbitMQ on Rocky Linux 8
Now, run the following command to install the RabbitMQ server to your system.
dnf install rabbitmq-server -y
Once the RabbitMQ server is installed, start the enable the RabbitMQ service with the following command:
systemctl start rabbitmq-server systemctl enable rabbitmq-server
Also Read
How to Install PostgreSQL 14 in Rocky Linux 8
Step 4 – Configure RabbitMQ
By default, RabbitMQ uses a guest user to connect from localhost. It is recommended to create an admin user and set a password to secure RabbitMQ.
To create an admin user, run the following command:
rabbitmqctl add_user admin
Sample output:
Adding user "admin" ... Password:
Next, assign administrator permissions to the admin user with the following command:
rabbitmqctl set_user_tags admin administrator
You can now verify the created user using the following command:
rabbitmqctl list_users
You will get the following output:
Listing users ... user tags admin [administrator] guest [administrator]
To add a new vhost, run the following command:
rabbitmqctl add_vhost /new_vhost
To list all vhosts, run the following command:
rabbitmqctl list_vhosts
You will get the following output:
Listing vhosts ... name / /new_vhost
Next, provide admin user permissions on vhosts using the following command:
rabbitmqctl set_permissions -p /new_vhost admin ".*" ".*" ".*"
Step 5 – Enable RabbitMQ Web UI
RabbitMQ provides a web interface to manage the RabbitMQ. However, it is disabled by default.
To enable the RabbitMQ web UI, run the following command:
rabbitmq-plugins enable rabbitmq_management
You will get the following output:
Enabling plugins on node rabbit@rockylinux: rabbitmq_management The following plugins have been configured: rabbitmq_management rabbitmq_management_agent rabbitmq_web_dispatch Applying plugin configuration to rabbit@rockylinux... The following plugins have been enabled: rabbitmq_management rabbitmq_management_agent rabbitmq_web_dispatch started 3 plugins.
Next, restart the RabbitMQ service to apply the changes.
systemctl restart rabbitmq-server
You can check the status of RabbitMQ using the following command:
rabbitmqctl status
You will get the following output:
Status of node rabbit@rockylinux ... Runtime OS PID: 19057 OS: Linux Uptime (seconds): 12 Is under maintenance?: false RabbitMQ version: 3.9.11 Node name: rabbit@rockylinux Erlang configuration: Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [jit] Erlang processes: 363 used, 1048576 limit Scheduler run queue: 1 Cluster heartbeat timeout (net_ticktime): 60 Plugins Enabled plugin file: /etc/rabbitmq/enabled_plugins Enabled plugins:
Step 6 – Access RabbitMQ Web UI
At this point, the RabbitMQ web UI is started and listens on port 15672. You can check it using the following command:
ss -antpl | grep 15672
You will get the following output:
LISTEN 0 128 0.0.0.0:15672 0.0.0.0:* users:(("beam.smp",pid=19057,fd=35))
Now, open your web browser and access the RabbitMQ web UI using the URL http://your-server-ip:15672. You should see the RabbitMQ login page:
Provide your admin username, password and click on the Login button. You should see the RabbitMQ dashboard on the following page:
Conclusion
In this post, we explained how to install and configure the RabbitMQ server on Rocky Linux 8. We also explained how to enable the RabbitMQ web UI and set an admin password. Hopefully, this guide will help you to install the RabbitMQ server in the production environment. Try it on dedicated hosts from Atlantic.Net!