In this article, we will show you how to install RabbitMQ on an Ubuntu 22.04 system. This guide is also applied on other latest Ubuntu systems.
RabbitMQ is an open-source message broker software that implements the Advanced Message Queuing Protocol (AMQP). It has since been extended with a plug-in architecture to support Streaming Text Oriented Messaging Protocol (STOMP), MQ Telemetry Transport (MQTT), and other protocols It is written in the Erlang programming language and is designed to support flexible messaging for applications in a distributed environment.
Message brokers like RabbitMQ allow different parts of a system to communicate by sending and receiving messages. A message is a simple piece of data that is sent from one application or system to another. The message broker acts as a middleman, routing messages between applications and allowing them to communicate without the need to know about each other’s implementation details.
Prerequisites
Before we begin, make sure you have the following prerequisites:
- A system running Ubuntu 22.04
- A user account with sudo privileges
Step 1: Add the RabbitMQ Repository
To install RabbitMQ on Ubuntu, we need to add the RabbitMQ package repository to our system. To do this, open a terminal and enter the following command:
sudo echo "deb https://dl.bintray.com/rabbitmq/debian focal main" | sudo tee /etc/apt/sources.list.d/bintray.rabbitmq.list
echo "deb https://dl.bintray.com/rabbitmq-erlang/debian focal erlang" | sudo tee /etc/apt/sources.list.d/bintray.erlang.list
This command adds the RabbitMQ repository to the list of package sources on your system.
Step 2: Add the RabbitMQ GPG Key
Next, we need to add the RabbitMQ GPG key to our system to verify the authenticity of the RabbitMQ packages we will be installing. To do this, run the following command:
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -
This command downloads the RabbitMQ GPG key and adds it to your system’s keyring.
Step 3: Install RabbitMQ
Now that we have added the RabbitMQ repository and GPG key to our system, we can proceed to install RabbitMQ. To do this, run the following command:
sudo apt update
sudo apt install rabbitmq-server
This will update the list of available packages and install RabbitMQ on your system.
Step 4: Start the RabbitMQ Service
After the installation is complete, start the RabbitMQ service by running the following command:
sudo systemctl start rabbitmq-server
To enable RabbitMQ to start automatically at boot, run the following command:
sudo systemctl enable rabbitmq-server
Step 5: Enable the Management Plugin
RabbitMQ comes with a built-in management plugin that provides a web-based management interface. To enable the plugin, run the following command:
sudo rabbitmq-plugins enable rabbitmq_management
Step 6: Setup Firewall
To configure the firewall on Ubuntu 22.04, you can use the ufw (Uncomplicated Firewall) utility. First, check the status of the firewall:
sudo ufw status
By default, the firewall should be inactive. To enable the firewall, run:
sudo ufw enable
To allow incoming connections to RabbitMQ, you will need to open the appropriate ports. RabbitMQ uses port 5672 for AMQP and port 15672 for the management interface. To allow incoming connections on these ports, run:
sudo ufw allow 5672
sudo ufw allow 15672
Step 7: Access the Rabbitmq management interface
After enabling the plugin, you can access the management interface by visiting the following URL in your web browser:
http://localhost:15672/
OR
http://YOUR-SERVER-IP:15672/
The default username and password for the management interface are both “guest“.
Conclusion
In this article, we have shown you how to install RabbitMQ on an Ubuntu 22.04 system. We have also shown you how to enable the management plugin and access the management interface. With RabbitMQ installed and configured, you can now start using it to manage your message queues and facilitate communication between different services and applications.