How-To

How to install RabbitMQ in Ubuntu 20.04

Pinterest LinkedIn Tumblr

In this guide we will explore how to install the latest release of RabbitMQ in Ubuntu 20.04 Server or Workstation

RabbitMQ is an open source message broker software that implements the Advanced Message Queuing Protocol (AMQP). RabbitMQ works by receiving messages from publishers (applications that publish them) and routes them to consumers (applications that process them).

Related Content

Prerequisites

To follow along, ensure you have the following

  • An updated Ubuntu Server/workstation
  • Access to the internet
  • Root access or user with Sudo access

Table of Content

  1. Updating the system
  2. Installing Erlang
  3. Installing RabbitMQ
  4. Starting and enabling rabbitmq-server service
  5. Optional: Enabling RabbitMQ Dashboard
  6. Basic RabbitMQ User Management Commands

1. Updating the system

Before proceeding, ensure that the server packages are up to date. Use this command to achieve that:

sudo apt update
sudo apt upgrade -y

2. Installing Erlang

The RabbitMQ package is found in the default OpenSUSE repos. Install it using this command:

sudo apt install -y erlang

4. Installing Rabbitmq

RabbitMQ can be found in the default Ubuntu repos. Install using this command:

sudo apt install -y rabbitmq-server

Package details can be queried using apt-cache command with the option policy.

$ apt-cache policy rabbitmq-server
rabbitmq-server:
  Installed: 3.8.2-0ubuntu1.3
  Candidate: 3.8.2-0ubuntu1.3
  Version table:
 *** 3.8.2-0ubuntu1.3 500
        500 http://us-west-2.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
        100 /var/lib/dpkg/status
     3.8.2-0ubuntu1 500
        500 http://us-west-2.ec2.archive.ubuntu.com/ubuntu focal/main amd64 Packages

5. Starting and enabling rabbitmq-server service

Start the service

sudo systemctl start rabbitmq-server

Then check the status to confirm its running

$ sudo systemctl status rabbitmq-server
● rabbitmq-server.service - RabbitMQ Messaging Server
     Loaded: loaded (/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-11-16 20:56:25 EAT; 1min 36s ago
   Main PID: 76008 (beam.smp)
     Status: "Initialized"
      Tasks: 87 (limit: 4631)
     Memory: 68.8M
     CGroup: /system.slice/rabbitmq-server.service
             ├─76004 /bin/sh /usr/sbin/rabbitmq-server
             ├─76008 /usr/lib/erlang/erts-10.6.4/bin/beam.smp -W w -A 64 -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -K true -- -root /usr/lib/erlang -progname erl -- -ho>
             ├─76247 erl_child_setup 65536
             ├─76270 inet_gethost 4
             └─76271 inet_gethost 4

Nov 16 20:56:22 ubuntu-client.citizix.com systemd[1]: Starting RabbitMQ Messaging Server...
Nov 16 20:56:25 ubuntu-client.citizix.com systemd[1]: rabbitmq-server.service: Supervising process 76008 which is not our child. We'll most likely not notice when it exits.
Nov 16 20:56:25 ubuntu-client.citizix.com systemd[1]: Started RabbitMQ Messaging Server.

Now you can enable it on boot

sudo systemctl enable rabbitmq-server

You can get status of rabbitmq internals:

$ sudo rabbitmqctl status

6. Optional: Enabling RabbitMQ Dashboard

Use the rabbitmq-plugins enable command to enable the management dashboard:

$ sudo rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node [email protected]:
rabbitmq_management
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
Applying plugin configuration to [email protected]
The following plugins have been enabled:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch

started 3 plugins.

The web service is up listening on port 15672

$ ss -tunlp | grep 15672
tcp   LISTEN 0       1024             0.0.0.0:15672        0.0.0.0:*

Access it by opening the URL http://[server IP]:15672 like http://127.0.0.1:15672

By default, the guest user exists and can connect only from localhost. You can log in with this user locally with the password “guest”

To be able to login on the network, create an admin user like below:

$ sudo rabbitmqctl add_user admin Secr3t
Adding user "admin" ...
Done. Don't forget to grant the user permissions to some virtual hosts! See 'rabbitmqctl help set_permissions' to learn more.

$ sudo rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator] ...

Login with this admin username and the password assigned. You should see an interface similar to below:

citizix - Rabbitmq Dashboard
citizix – Rabbitmq Dashboard

7. Basic RabbitMQ User Management Commands

Delete User:

sudo rabbitmqctl delete_user user

Change User Password:

sudo rabbitmqctl change_password user strongpassword

Create new Virtualhost:

sudo rabbitmqctl add_vhost /my_vhost

List available Virtualhosts:

sudo rabbitmqctl list_vhosts

Delete a virtualhost:

sudo rabbitmqctl delete_vhost /myvhost

Grant user permissions for vhost:

sudo rabbitmqctl set_permissions -p /myvhost user ".*" ".*" ".*"

List vhost permissions:

sudo rabbitmqctl list_permissions -p /myvhost

To list user permissions:

rabbitmqctl list_user_permissions user

Delete user permissions:

rabbitmqctl clear_permissions -p /myvhost user

Conclusion

We have managed to install Rabbitmq in this guide.

I am a Devops Engineer, but I would describe myself as a Tech Enthusiast who is a fan of Open Source, Linux, Automations, Cloud and Virtualization. I love learning and exploring new things so I blog in my free time about Devops related stuff, Linux, Automations and Open Source software. I can also code in Python and Golang.

Write A Comment