RabbitMQ is an open-source message broker software that implements the Advanced Message Queuing Protocol (AMQP). It is written in Erlang and supports multiple messaging protocols such as MQTT, STOMP, and HTTP. RabbitMQ is widely used for its reliability, scalability, and ease of use. In this tutorial, we’ll walk through the process of how to set up RabbitMQ on Rocky Linux, an enterprise-grade Linux distribution.
Table of Contents:
- Prerequisites
- Installing Erlang
- Installing RabbitMQ
- Configuring RabbitMQ
- Managing RabbitMQ
- Setting up RabbitMQ Web Management Console
- Conclusion
How to Set up RabbitMQ on Rocky Linux
Prerequisites
Before proceeding, make sure you have:
- A Rocky Linux system with administrative privileges.
- A stable internet connection.
Installing Erlang on Rocky Linux
RabbitMQ requires Erlang to be installed on the system. To install Erlang, first, add the Erlang Solutions repository by running the following commands:
sudo rpm --import https://packages.erlang-solutions.com/rpm/erlang_solutions.asc
sudo tee /etc/yum.repos.d/erlang-solutions.repo << EOF
[erlang-solutions]
name=erlang-solutions
baseurl=https://packages.erlang-solutions.com/rpm/rocky/8/x86_64
gpgcheck=1
gpgkey=https://packages.erlang-solutions.com/rpm/erlang_solutions.asc
enabled=1
EOF
Next, update your package index and install Erlang:
sudo dnf update
sudo dnf install -y erlang
Installing RabbitMQ on Rocky Linux
To install RabbitMQ, first, add the RabbitMQ repository by creating a new repository file:
sudo tee /etc/yum.repos.d/rabbitmq.repo << EOF
[rabbitmq-server]
name=rabbitmq-server
baseurl=https://packagecloud.io/rabbitmq/rabbitmq-server/el/8/$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOF
Next, update your package index and install RabbitMQ:
sudo dnf update
sudo dnf install -y rabbitmq-server
Once the installation is complete, enable and start the RabbitMQ service:
sudo systemctl enable rabbitmq-server
sudo systemctl start rabbitmq-server
You can check the status of the RabbitMQ service by running:
sudo systemctl status rabbitmq-server
Configuring RabbitMQ on Rocky Linux
RabbitMQ can be configured using the rabbitmq.conf
file located in the /etc/rabbitmq/
directory. You can modify this file according to your requirements.
For example, to enable the RabbitMQ management plugin, open the rabbitmq.conf
file:
sudo nano /etc/rabbitmq/rabbitmq.conf
Add the following line to the file:
management.load_definitions = /etc/rabbitmq/definitions.json
Save and close the file.
Managing RabbitMQ on Rocky Linux
You can use the rabbitmqctl
command to manage your RabbitMQ server. Some common tasks include:
- List all queues:
sudo rabbitmqctl list_queues
- List all exchanges:
sudo rabbitmqctl list_exchanges
- List all bindings:
sudo rabbitmqctl list_bindings
- Add a new user:
sudo rabbitmqctl add_user <username> <password>
- Set user tags:
sudo rabbitmqctl set_user_tags <username> <tag>
- Set permissions for a user:
sudo rabbitmqctl set_permissions -p <vhost> <username> <conf> <write> <read>
- Delete a user:
sudo rabbitmqctl delete_user <username>
Setting up RabbitMQ Web Management Console
The RabbitMQ Web Management Console provides a user-friendly interface to manage your RabbitMQ server. To enable the console, run the following command:
sudo rabbitmq-plugins enable rabbitmq_management
By default, the management console is accessible on port 15672. You can create an administrative user for the console by running:
sudo rabbitmqctl add_user admin my_secure_password
sudo rabbitmqctl set_user_tags admin administrator
Replace my_secure_password
with a strong password of your choice.
Now, you can access the RabbitMQ Web Management Console by opening your web browser and navigating to http://<your_server_ip>:15672
. Log in with the credentials you created earlier (e.g., admin and your chosen password).
Conclusion
In this tutorial, you have learned how to install and configure RabbitMQ on Rocky Linux. You have also learned how to manage your RabbitMQ server using the command line and the Web Management Console. With RabbitMQ installed, you can now use it to build scalable and reliable messaging applications. If you want to explore more tutorials on Rocky Linux, check out these articles: