Install RabbitMQ on Ubuntu 22.04/Ubuntu 20.04

|
Last Updated:
|
|

In this tutorial, you will learn how to install RabbitMQ on Ubuntu 22.04/Ubuntu 20.04. RabbitMQ is the most widely deployed open source message broker written in the Erlang programming language and is built on the Open Telecom Platform framework for clustering and failover. It implements the Advanced Message Queuing Protocol (AMQP), Streaming Text Oriented Messaging Protocol (STOMP), MQ Telemetry Transport (MQTT), and other protocols.

Read more on RabbitMQ Features page.

Install RabbitMQ on Ubuntu 22.04/Ubuntu 20.04

RabbitMQ is available on the default Ubuntu repositories. However, the available versions may not be up-to-date.

Verify the available versions of RabbitMQ on Ubuntu 22.04/Ubuntu 20.04 repositories;

Ubuntu 22.04;

apt-cache policy rabbitmq-server

rabbitmq-server:
  Installed: (none)
  Candidate: 3.9.13-1
  Version table:
     3.9.13-1 500
        500 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 Packages

Ubuntu 20.04;

apt-cache policy rabbitmq-server

rabbitmq-server:
  Installed: (none)
  Candidate: 3.8.2-0ubuntu1.3
  Version table:
     3.8.2-0ubuntu1.3 500
        500 http://ke.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://ke.archive.ubuntu.com/ubuntu focal-security/main amd64 Packages
     3.8.2-0ubuntu1 500
        500 http://ke.archive.ubuntu.com/ubuntu focal/main amd64 Packages

As you can see, Ubuntu 22.04 provides RabbitMQ version 3.9.13 while Ubuntu 20.04 provides version 3.9.2.

According to RabbitMQ release series page, v3.9.13 is the current stable release, as of this writing. This means that Ubuntu 22.04 repositories provides the latest versions of RabbitMQ.

Install RabbitMQ on Ubuntu 22.04

As confirmed above, Ubuntu 22.04 repositories provides the current release versions of RabbitMQ.

You can then install RabbitMQ on Ubuntu 22.04 by running the command below;

apt install rabbitmq-server

Sample command installation output. Note that RabbitMQ will be installed alongside all other package dependencies including Erlang packages.


Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  erlang-asn1 erlang-base erlang-crypto erlang-eldap erlang-ftp erlang-inets erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key erlang-runtime-tools
  erlang-snmp erlang-ssl erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl libsctp1 socat
Suggested packages:
  erlang erlang-manpages erlang-doc lksctp-tools
The following NEW packages will be installed:
  erlang-asn1 erlang-base erlang-crypto erlang-eldap erlang-ftp erlang-inets erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key erlang-runtime-tools
  erlang-snmp erlang-ssl erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl libsctp1 rabbitmq-server socat
0 upgraded, 20 newly installed, 0 to remove and 25 not upgraded.
Need to get 35.3 MB of archives.
After this operation, 56.1 MB of additional disk space will be used.
Get:1 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-base amd64 1:24.2.1+dfsg-1 [9,832 kB]
Get:2 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-asn1 amd64 1:24.2.1+dfsg-1 [911 kB]
Get:3 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-crypto amd64 1:24.2.1+dfsg-1 [157 kB]
Get:4 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-public-key amd64 1:24.2.1+dfsg-1 [783 kB]
Get:5 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-mnesia amd64 1:24.2.1+dfsg-1 [891 kB]
Get:6 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-runtime-tools amd64 1:24.2.1+dfsg-1 [227 kB]
Get:7 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-ssl amd64 1:24.2.1+dfsg-1 [1,581 kB]
Get:8 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-eldap amd64 1:24.2.1+dfsg-1 [125 kB]
Get:9 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-ftp amd64 1:24.2.1+dfsg-1 [84.4 kB]
Get:10 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-tftp amd64 1:24.2.1+dfsg-1 [103 kB]
Get:11 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-inets amd64 1:24.2.1+dfsg-1 [627 kB]
Get:12 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-snmp amd64 1:24.2.1+dfsg-1 [1,894 kB]
Get:13 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-os-mon amd64 1:24.2.1+dfsg-1 [91.2 kB]
Get:14 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-parsetools amd64 1:24.2.1+dfsg-1 [194 kB]
Get:15 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-syntax-tools amd64 1:24.2.1+dfsg-1 [303 kB]
Get:16 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-tools amd64 1:24.2.1+dfsg-1 [635 kB]                                                                    
Get:17 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 erlang-xmerl amd64 1:24.2.1+dfsg-1 [1,382 kB]                                                                  
Get:18 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 libsctp1 amd64 1.0.19+dfsg-1 [9,374 B]                                                                         
Get:19 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 socat amd64 1.7.4.1-3ubuntu3 [349 kB]                                                                          
Get:20 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 rabbitmq-server all 3.9.13-1 [15.2 MB]                                                                         
Fetched 35.3 MB in 13s (2,637 kB/s)                                                                                                                                        
Selecting previously unselected package erlang-base.
(Reading database ... 159131 files and directories currently installed.)
Preparing to unpack .../00-erlang-base_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-base (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-asn1.
Preparing to unpack .../01-erlang-asn1_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-asn1 (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-crypto.
Preparing to unpack .../02-erlang-crypto_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-crypto (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-public-key.
Preparing to unpack .../03-erlang-public-key_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-public-key (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-mnesia.
Preparing to unpack .../04-erlang-mnesia_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-mnesia (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-runtime-tools.
Preparing to unpack .../05-erlang-runtime-tools_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-runtime-tools (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-ssl.
Preparing to unpack .../06-erlang-ssl_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-ssl (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-eldap.
Preparing to unpack .../07-erlang-eldap_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-eldap (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-ftp.
Preparing to unpack .../08-erlang-ftp_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-ftp (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-tftp.
Preparing to unpack .../09-erlang-tftp_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-tftp (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-inets.
Preparing to unpack .../10-erlang-inets_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-inets (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-snmp.
Preparing to unpack .../11-erlang-snmp_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-snmp (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-os-mon.
Preparing to unpack .../12-erlang-os-mon_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-os-mon (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-parsetools.
Preparing to unpack .../13-erlang-parsetools_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-parsetools (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-syntax-tools.
Preparing to unpack .../14-erlang-syntax-tools_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-syntax-tools (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-tools.
Preparing to unpack .../15-erlang-tools_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-tools (1:24.2.1+dfsg-1) ...
Selecting previously unselected package erlang-xmerl.
Preparing to unpack .../16-erlang-xmerl_1%3a24.2.1+dfsg-1_amd64.deb ...
Unpacking erlang-xmerl (1:24.2.1+dfsg-1) ...
Selecting previously unselected package libsctp1:amd64.
Preparing to unpack .../17-libsctp1_1.0.19+dfsg-1_amd64.deb ...
Unpacking libsctp1:amd64 (1.0.19+dfsg-1) ...
Selecting previously unselected package socat.
Preparing to unpack .../18-socat_1.7.4.1-3ubuntu3_amd64.deb ...
Unpacking socat (1.7.4.1-3ubuntu3) ...
Selecting previously unselected package rabbitmq-server.
Preparing to unpack .../19-rabbitmq-server_3.9.13-1_all.deb ...
Unpacking rabbitmq-server (3.9.13-1) ...
Setting up erlang-base (1:24.2.1+dfsg-1) ...
Searching for services which depend on erlang and should be started... none found.
Setting up erlang-xmerl (1:24.2.1+dfsg-1) ...
Setting up erlang-syntax-tools (1:24.2.1+dfsg-1) ...
Setting up erlang-parsetools (1:24.2.1+dfsg-1) ...
Setting up socat (1.7.4.1-3ubuntu3) ...
Setting up erlang-asn1 (1:24.2.1+dfsg-1) ...
Setting up erlang-tftp (1:24.2.1+dfsg-1) ...
Setting up libsctp1:amd64 (1.0.19+dfsg-1) ...
Setting up erlang-mnesia (1:24.2.1+dfsg-1) ...
Setting up erlang-crypto (1:24.2.1+dfsg-1) ...
Setting up erlang-runtime-tools (1:24.2.1+dfsg-1) ...
Setting up erlang-tools (1:24.2.1+dfsg-1) ...
Setting up erlang-snmp (1:24.2.1+dfsg-1) ...
Setting up erlang-public-key (1:24.2.1+dfsg-1) ...
Setting up erlang-ssl (1:24.2.1+dfsg-1) ...
Setting up erlang-os-mon (1:24.2.1+dfsg-1) ...
Setting up erlang-eldap (1:24.2.1+dfsg-1) ...
Setting up erlang-ftp (1:24.2.1+dfsg-1) ...
Setting up erlang-inets (1:24.2.1+dfsg-1) ...
Setting up rabbitmq-server (3.9.13-1) ...
Adding group `rabbitmq' (GID 137) ...
Done.
Adding system user `rabbitmq' (UID 130) ...
Adding new user `rabbitmq' (UID 130) with group `rabbitmq' ...
Not creating home directory `/var/lib/rabbitmq'.
Created symlink /etc/systemd/system/multi-user.target.wants/rabbitmq-server.service → /lib/systemd/system/rabbitmq-server.service.
Processing triggers for man-db (2.10.1-1) ...
Processing triggers for libc-bin (2.35-0ubuntu1) ...

Install RabbitMQ on Ubuntu 20.04

To install latest version of RabbitMQ on Ubuntu 20.04, you need to install the Cloudsmith RabbitMQ repository and modern Erlang repository as follows;

Install Team RabbitMQ’s main signing key;

curl -1sLf "https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA" | gpg --dearmor > /etc/apt/trusted.gpg.d/rabbitmq.team.gpg

Install Erlang repository GPG signing key

curl -1sLf https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key | gpg --dearmor > /etc/apt/trusted.gpg.d/erlang.gpg

Install RabbitMQ repository GPG signing key;

curl -1sLf https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key | gpg --dearmor > /etc/apt/trusted.gpg.d/rabbitmq.gpg

Install RabbitMQ and Erlang Repositories;


cat > /etc/apt/sources.list.d/rabbitmq.list << 'EOL'
## Erlang
deb  https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/deb/ubuntu focal main
deb-src https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/deb/ubuntu focal main

## Provides RabbitMQ
deb https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/deb/ubuntu focal main
deb-src  https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/deb/ubuntu focal main
EOL

Run system update;

apt update

Next, install RabbitMQ on Ubuntu 20.04;

apt install rabbitmq-server

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  erlang-asn1 erlang-base erlang-crypto erlang-eldap erlang-ftp erlang-inets erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key erlang-runtime-tools
  erlang-snmp erlang-ssl erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl libsctp1
Suggested packages:
  erlang erlang-manpages erlang-doc lksctp-tools
The following NEW packages will be installed:
  erlang-asn1 erlang-base erlang-crypto erlang-eldap erlang-ftp erlang-inets erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key erlang-runtime-tools
  erlang-snmp erlang-ssl erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl libsctp1 rabbitmq-server
0 upgraded, 19 newly installed, 0 to remove and 150 not upgraded.
Need to get 32.4 MB of archives.
After this operation, 64.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Running RabbitMQ Service

When installed, RabbitMQ service is started and enabled to run on system boot;

systemctl status rabbitmq-server

Output;


● rabbitmq-server.service - RabbitMQ Messaging Server
     Loaded: loaded (/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-03-01 23:45:34 EAT; 22min ago
   Main PID: 3036 (beam.smp)
      Tasks: 23 (limit: 2306)
     Memory: 85.9M
        CPU: 15.014s
     CGroup: /system.slice/rabbitmq-server.service
             ├─3036 /usr/lib/erlang/erts-12.2.1/bin/beam.smp -W w -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 5000000 -stbt db -zdbbl 1>
             ├─3050 erl_child_setup 65536
             ├─3116 inet_gethost 4
             └─3117 inet_gethost 4

Mac 01 23:45:17 ubuntu2204 systemd[1]: Starting RabbitMQ Messaging Server...
Mac 01 23:45:34 ubuntu2204 systemd[1]: Started RabbitMQ Messaging Server.

You can control/manage the service using systemctl like start, stop, restart…

You can also run RabbitMQ command line tools. See examples given on the RabbitMQ configuration page.

  • Check if the local node is running and CLI tools can successfully authenticate with it
rabbitmq-diagnostics ping
  • prints enabled components (applications), TCP listeners, memory usage breakdown, alarms and so on
rabbitmq-diagnostics status
  • prints cluster membership information
rabbitmq-diagnostics cluster_status
  • prints effective node configuration
rabbitmq-diagnostics environment
  • Lists queues and their properties
rabbitmq-diagnostics list_queues

Enable RabbitMQ Management UI

To enable RabbitMQ management UI, first enable the management plugin.

rabbitmq-plugins enable rabbitmq_management

Sample command output;


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

started 3 plugins.

Create administrative user for full management UI and HTTP API access;

rabbitmqctl add_user kifarunixadmin changemepassword

Command Syntax:

rabbitmqctl [--node <node>] [--longnames] [--quiet] add_user <username> <password>

If you want to change the password use;

rabbitmqctl change_password <username> <new-password>

Assign the user administrative rights;

rabbitmqctl set_user_tags kifarunixadmin administrator

Command Syntax;

rabbitmqctl [--node <node>] [--longnames] [--quiet] set_user_tags <username> <tag> [...]

RabbitMQ Management UI Access

You can now access RabbitMQ web management UI via the address http://<server-IP – or domain>:15672

15672, 15671 are used for HTTP API clients, management UI and rabbitmqadmin.

ss -altnp | grep 56

LISTEN 0      128          0.0.0.0:25672      0.0.0.0:*    users:(("beam.smp",pid=3036,fd=18))                   
LISTEN 0      1024         0.0.0.0:15672      0.0.0.0:*    users:(("beam.smp",pid=3036,fd=35))                   
LISTEN 0      128                *:5672             *:*    users:(("beam.smp",pid=3036,fd=33))

Open the port on Firewall to allow external access.

Login Interface

Install RabbitMQ on Ubuntu 22.04/Ubuntu 20.04

Use the credentials created above to login to RabbitMQ UI;

Install RabbitMQ on Ubuntu 22.04/Ubuntu 20.04

And there you go! you have learnt how to install RabbitMQ on Ubuntu.

Read more on Getting Started with RabbitMQ.

Other Tutorials

Install Erlang on Ubuntu 22.04/Ubuntu 20.04

Install Wine on Ubuntu 22.04

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment