Installing RabbitMq
This section provides a detailed guide on installing and configuring RabbitMQ.
RabbitMQ, a robust message broker facilitates communication between distributed applications. RabbitMQ is critical for managing asynchronous workflows and ensuring reliable message delivery in a microservices architecture. This page covers setting up RabbitMQ, enabling necessary plugins, creating users, configuring permissions, and customizing settings for seamless integration with your deployment environment.
Prerequisites
Make sure the following things are in place, before installing:
- Root access to the VM.
- Redis is installed in the VM.
To install and configure RabbitMQ, follow the steps below:
- Run the following bash command to Install necessary utilities for RabbitMQ
setup.
dnf install socat logrotate -y
- Download the Erlang package required for
RabbitMQ.
curl -LO -C - https://github.com/rabbitmq/erlang-rpm/releases/download/v26.2.5/erlang-26.2.5-1.el8.x86_64.rpm
- Use the following command to install the downloaded Erlang
package.
sudo dnf install ./erlang-26.2.5-1.el8.x86_64.rpm
- Run the following script to set up the RabbitMQ package
repository.
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash
- Install the RabbitMQ using the package
manager.
dnf install -y rabbitmq-server
- Enable the RabbitMQ service to start automatically on boot and then start the
service.
sudo systemctl enable rabbitmq-server sudo systemctl start rabbitmq-server
- Enable the management plugin to provide a web-based interface for
RabbitMQ.
rabbitmq-plugins enable rabbitmq_management
- Now, RabbitMQ is now installed and configured. You can access the RabbitMQ
Management UI at
http://<server-ip>:15672
using default credentials (guest/guest
).
Post Configuration for RabbitMQ
After enabling RabbitMQ and the management plugin, to configure the system further follow these additional steps below:
- Navigate to the RabbitMQ configuration directory to add configuration
files:
cd /etc/rabbitmq/
- Create the
definitions.json
file:vi definitions.json
- Paste the following content into
definitions.json
to set up a user, permissions, and virtual host:{ "users": [ { "name": "celery", "password_hash": "fa604aceeeaae520de8742410200d620edc4a6101fb2971cd706b4cc19141dce", "hashing_algorithm": "rabbit_password_hashing_sha256", "tags": "administrator" } ], "vhosts": [ { "name": "/" } ], "permissions": [ { "user": "celery", "vhost": "/", "configure": ".*", "write": ".*", "read": ".*" } ], "queues": [], "exchanges": [], "bindings": [] }
- Save and exit the file. Now, update the
rabbitmq.conf
file:vi rabbitmq.conf
- Add the following line to load the definitions file during RabbitMQ
startup.
load_definitions = /etc/rabbitmq/definitions.json
- Save and exit the file. Now, restart RabbitMQ to apply the
changes:
sudo systemctl stop rabbitmq-server sudo systemctl start rabbitmq-server
- RabbitMQ is now configured with a predefined user, permissions, and virtual host.