How to Install RabbitMQ on Debian 11 Server Tutorial (Step by Step)

How to Install RabbitMQ on Debian 11 Server. This article will introduce what RabbitMQ is with its benefits and then we will move onto installation phase. Let’s start. 

What is RabbitMQ

RabbitMQ is a free and open source message queue solution written in Erlang OTP. It is built based on the “Open telecom platform framework” for clustering message requests from the client. RabbitMQ server allows different services in your application to communicate with each other without worrying about message loss when fulfilling different quality of service (QoS) requirements. It provides a common platform to send and receive a message and facilitates encryption services to maintain confidentiality. It is used by many large companies including Zalando, Boomerang, WeWork, WunderList and many more. It is highly beneficial for messaging, and it can be integrated effortlessly. It has the ability to interpret the system’s data in a more simple and readable format.

Pros of RabbitMQ

  • RabbitMQ is a reliable open source message broker.
  • Supports message protocols such as AMQP, MQTT, STOMP and HTTP.
  • Delivery acknowledgments that leads to better reliability of the message queue by reducing message loss.
  • Flexible routing that allows for the delivery of specific messages to specific queues and specific consumers.
  • Lightweight so easily deployed to enterprise and public clouds.

Follow this post below to install RabbitMQ on Debian 11 server.

Install RabbitMQ on Debian 11 Server

Before starting, it is recommended to update and upgrade all system packages to the latest version. You can update them using the following command:

				
					apt-get update -y
apt-get upgrade -y
				
			

Once all the packages are updated, you will also need to install some required dependencies on your server. You can install all the required packages with the following command:

				
					apt-get install software-properties-common curl gnupg2 apt-transport-https -y
				
			

Once all the packages are installed, you can proceed to the next step.

Install Erlang on Debian 11

Next step is to install Erlang package as a prerequisite on your server. By default, the Erlang package is not included in the Debian 11 default repository. So you will need to add the Erlang repository to your server. You can install it by running the following command:

				
					wget https://packages.erlang-solutions.com/erlang/debian/pool/esl-erlang_23.1.5-1~debian~stretch_amd64.deb
dpkg -i esl-erlang_23.1.5-1~debian~stretch_amd64.deb
				
			

If you get any dependency error, then run the following command to install all required dependencies:

				
					apt-get install -f
				
			

Once the repository is installed, update the repository and install the Erlang with the following command:

				
					apt-get update -y
apt-get install erlang erlang-nox
				
			

When Erlang is installed, verify Erlang using the following command:

				
					erl -v
				
			

You will get the following output:

				
					Erlang/OTP 23 [erts-11.1.8]  [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1]

Eshell V11.1.8  (abort with ^G)
1> 
				
			

Press CTRL+G then type q to exit from the Erlang shell.

Install RabbitMQ Server

By default, the RabbitMQ server is not available in the Debian 11 default repository. So you will need to add the RabbitMQ repository to your server. You can add it by running the following command:

				
					add-apt-repository 'deb http://www.rabbitmq.com/debian/ testing main'
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | apt-key add -
				
			

You will get the following output:

				
					Resolving www.rabbitmq.com (www.rabbitmq.com)... Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
104.20.10.224, 104.20.11.224, 172.67.16.25, ...
Connecting to www.rabbitmq.com (www.rabbitmq.com)|104.20.10.224|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3187 (3.1K) [application/pgp-signature]
Saving to: ‘STDOUT’

-                                   100%[=================================================================>]   3.11K  --.-KB/s    in 0s      

2022-03-18 07:02:10 (15.6 MB/s) - written to stdout [3187/3187]

OK

				
			

Once the repository is installed, update the repository cache and install the RabbitMQ server with the following command:

				
					apt-get update -y
apt-get install rabbitmq-server -y
				
			

When RabbitMQ server is installed, start and enable the RabbitMQ service with the following command:

				
					systemctl start rabbitmq-server
systemctl enable rabbitmq-server
				
			

You can now check the status of the RabbitMQ with the following command:

				
					systemctl status  rabbitmq-server
				
			

You will get the following output:

				
					● rabbitmq-server.service - RabbitMQ Messaging Server
     Loaded: loaded (/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-03-18 07:03:23 UTC; 12s ago
   Main PID: 7617 (beam.smp)
     Status: "Initialized"
      Tasks: 84 (limit: 2341)
     Memory: 80.5M
        CPU: 10.623s
     CGroup: /system.slice/rabbitmq-server.service
             ├─7617 /usr/lib/erlang/erts-11.1.8/bin/beam.smp -W w -K true -A 64 -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmc>
             ├─7715 erl_child_setup 65536
             ├─7761 inet_gethost 4
             └─7762 inet_gethost 4

Mar 18 07:03:13 debian11 systemd[1]: Starting RabbitMQ Messaging Server...
Mar 18 07:03:23 debian11 systemd[1]: Started RabbitMQ Messaging Server.
				
			

When finished please proceed to the next step.

Create RabbitMQ Administrative User

Next in how to install RabbitMQ on Debian 11 server is to create an administrative user to authenticate RabbitMQ. You can create it by running the following command:

				
					rabbitmqctl add_user admin admin-password
				
			

You will get the following output:

				
					Adding user "admin" ...
				
			

Please set an administrator tag on the admin account using the following command:

				
					rabbitmqctl set_user_tags admin administrator
				
			

Next, set the required permission on the admin account using the following command:

				
					rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
				
			

You can now list all permissions using the following command:

				
					rabbitmqctl list_permissions -p /
				
			

You will get the following output:

				
					Listing permissions for vhost "/" ...
user	configure	write	read
admin	.*	.*	.*
guest	.*	.*	.*
				
			

Once you are finished, you can proceed to the next step.

Install RabbitMQ Management Dashboard

Next, you will need to install the RabbitMQ management plugin to access the RabbitMQ web interface. You can enable it by running the following command:

				
					rabbitmq-plugins enable rabbitmq_management
				
			

You will get the following output:

				
					Enabling plugins on node rabbit@server:
rabbitmq_management
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@server...
The following plugins have been enabled:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch

started 3 plugins.

				
			

At this point, the RabbitMQ management plugin is started and listening on port 15672. You can check it by running the following command:

				
					ss -tunelp | grep 15672
				
			

You will get the listening port in the following output:

				
					tcp   LISTEN 0      1024                          0.0.0.0:15672      0.0.0.0:*    users:(("beam.smp",pid=7617,fd=96)) uid:108 ino:26038 sk:8 cgroup:/system.slice/rabbitmq-server.service <->         
				
			

Configure Firewall

If you are using the UFW firewall on your system, then you will need to allow SSH and RabbitMQ ports via UFW firewall. You can allow all of them by running the following command:

				
					ufw allow ssh
ufw allow 5672/tcp
ufw allow 15672/tcp
				
			

Please enable the UFW firewall with the following command:

				
					ufw enable
				
			

Next, verify the UFW firewall status using the following command:

				
					ufw status
				
			

You will get the following output:

				
					Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere                  
5672/tcp                   ALLOW       Anywhere                  
15672/tcp                  ALLOW       Anywhere                  
22/tcp (v6)                ALLOW       Anywhere (v6)             
5672/tcp (v6)              ALLOW       Anywhere (v6)             
15672/tcp (v6)             ALLOW       Anywhere (v6)             
				
			

Access RabbitMQ Admin Interface

You can now open your web browser and type the URL http://your-server-ip:15672/. You should see the RabbitMQ login screen on the following page:

Provide your admin username, password, and click on the login button. You should see the RabbitMQ dashboard on the following page:

Backup RabbitMQ Configurations

The RabbitMQ also provides a rabbitmqadmin command line utility that allows you to backup RabbitMQ configuration including, users, vhosts, queues, exchanges and bindings.

First, download the rabbitmqadmin utility using the following command:

				
					wget http://rabbitmq-server-ip:15672/cli/rabbitmqadmin
				
			

Once the rabbitmqadmin is downloaded, copy it to the system location with the following command:

				
					mv rabbitmqadmin /usr/bin/
				
			

Next, set proper permission to the rabbitmqadmin binary:

				
					chmod 775 /usr/bin/rabbitmqadmin
				
			

You can now verify the rabbitmqadmin version with the following command:

				
					rabbitmqadmin --version
				
			

You will get the following output:

				
					rabbitmqadmin 3.8.9
				
			

Now, backup the RabbitMQ configuration using the following command:

				
					rabbitmqadmin export rabbitmq-backup-config.json
				
			

You will get the following output:

				
					Exported definitions for localhost to "rabbitmq-backup-config.json"
				
			

If you want to restore the RabbitMQ backup, run the following command:

				
					rabbitmqadmin import rabbitmq-backup.json 
				
			

How to Install RabbitMQ on Debian 11 Server Conclusion

RabbitMQ is a platform to send and receive messages and it safely delivers your messages until it is received. RabbitMQ is a solid message queue software but there are alternatives such as Kafka, ActiveMQ or Redis

 

In this post, we explained how to install the RabbitMQ on Debian 11 server. We also explained how to enable the RabbitMQ management plugin, access the RabbitMQ dashboard and backup and restore the RabbitMQ configuration. You can now use RabbitMQ as a message brocker service with your application.

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x