How to install Latest RabbitMQ Server on Ubuntu 18.04 LTS

(: December 10, 2018)

RabbitMQ is an open source message broker software that implements the Advanced Message Queuing Protocol (AMQP) and Streaming Text Oriented Messaging Protocol, Message Queuing Telemetry Transport, and other protocols via a Plugins.

The work of a Messaging broker is to receive messages from publishers (applications that publish them) and route them to consumers (applications that process them). AMQP is a messaging protocol that enables conforming client applications to communicate with conforming messaging middleware brokers.

Follow the steps below to install RabbitMQ Server on Ubuntu 18.04 LTS.{text-align:left} img{margin:0 auto 0 0}

Step 1: Install Erlang/OTP

RabbitMQ requires Erlang to be installed first before it can run. Install Erlang on Ubuntu 18.04 system using our previous guide:

How to install Latest Erlang on Ubuntu 18.04 LTS

Once Erlang has been installed, proceed to step 2.

Step 2: Add RabbitMQ Repository To Ubuntu 18.04

Import RabbitMQ:

wget -O- | sudo apt-key add -
wget -O- | sudo apt-key add -

Now add RabbitMQ Repository To Ubuntu 18.04:

echo "deb $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/rabbitmq.list

Step 2: Install RabbitMQ Server Ubuntu 18.04 LTS

To install RabbitMQ Server Ubuntu 18.04, update apt list, then install rabbitmq-server package

sudo apt update
sudo apt -y install rabbitmq-server

After installation, RabbitMQ service is started and enabled to start on boot. To check the status, run:

$ sudo systemctl status  rabbitmq-server.service 
* rabbitmq-server.service - RabbitMQ broker
   Loaded: loaded (/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2018-10-24 13:14:42 PDT; 1min 11s ago
 Main PID: 9525 (beam.smp)
   Status: "Initialized"
    Tasks: 87 (limit: 1111)
   CGroup: /system.slice/rabbitmq-server.service
           |-9525 /usr/lib/erlang/erts-10.1/bin/beam.smp -W w -A 64 -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 50
           |-9622 /usr/lib/erlang/erts-10.1/bin/epmd -daemon
           |-9778 erl_child_setup 32768
           |-9797 inet_gethost 4
           `-9798 inet_gethost 4

Oct 24 13:14:38 ubuntu-01 rabbitmq-server[9525]:   ##  ##
Oct 24 13:14:38 ubuntu-01 rabbitmq-server[9525]:   ##  ##      RabbitMQ 3.7.8. Copyright (C) 2007-2018 Pivotal Software, Inc.
Oct 24 13:14:38 ubuntu-01 rabbitmq-server[9525]:   ##########  Licensed under the MPL.  See
Oct 24 13:14:38 ubuntu-01 rabbitmq-server[9525]:   ######  ##
Oct 24 13:14:38 ubuntu-01 rabbitmq-server[9525]:   ##########  Logs: /var/log/rabbitmq/[email protected]
Oct 24 13:14:38 ubuntu-01 rabbitmq-server[9525]:                     /var/log/rabbitmq/[email protected]_upgrade.log
Oct 24 13:14:38 ubuntu-01 rabbitmq-server[9525]:               Starting broker...
Oct 24 13:14:42 ubuntu-01 rabbitmq-server[9525]: systemd unit for activation check: "rabbitmq-server.service"
Oct 24 13:14:42 ubuntu-01 systemd[1]: Started RabbitMQ broker.
Oct 24 13:14:42 ubuntu-01 rabbitmq-server[9525]:  completed with 0 plugins.

You can confirm if the service is configured to start on boot using the command:

$ systemctl is-enabled rabbitmq-server.service 

If it returns disabled, enable it by running:

sudo systemctl enable rabbitmq-server

Step 3: Enable the RabbitMQ Management Dashboard (Optional)

You can optionally enable the RabbitMQ Management Web dashboard for easy management.

sudo rabbitmq-plugins enable rabbitmq_management

The Web service should be listening on TCP port 15672

# ss -tunelp | grep 15672
tcp   LISTEN  0       128          *      users:(("beam.smp",pid=9525,fd=71)) uid:111 ino:39934 sk:9 <->

If you have an active UFW firewall, open both ports 5672 and 15672

sudo ufw allow proto tcp from any to any port 5672,15672

Access it by opening the URL http://[server IP|Hostname]:15672

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

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

rabbitmqctl add_user admin StrongPassword
rabbitmqctl set_user_tags admin administrator

Login with this admin username and the password assigned.

Step 4: Set RabbitMQ Cluster (Optional)

If you need to achieve high availability and higher throughput, consider configuring RabbitMQ cluster on your Ubuntu 18.04 servers by following the guide below:

How to Configure RabbitMQ Cluster on Ubuntu 18.04 LTS

RabbitMQ User Management Commands

Delete User:

rabbitmqctl delete_user user

Change User Password:

rabbitmqctl change_password user strongpassword

Create new Virtualhost:

rabbitmqctl add_vhost /my_vhost

List available Virtualhosts:

rabbitmqctl list_vhosts

Delete a virtualhost:

rabbitmqctl delete_vhost /myvhost

Grant user permissions for vhost:

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

List vhost permissions:

rabbitmqctl list_permissions -p /myvhost

To list user permissions:

rabbitmqctl list_user_permissions user

Delete user permissions:

rabbitmqctl clear_permissions -p /myvhost user

The next article to read is:

How to Backup and Restore RabbitMQ Data & Configurations

To install RabbitMQ on CentOS 7 / CentOS 6 server, see:

Installing RabbitMQ on CentOS 6 and CentOS 7{text-align:left} img{margin:0 auto 0 0}

Related Posts