Skip to content

Installing RabbitMQ

Victor Gentle edited this page Jul 21, 2024 · 2 revisions

Installing RabbitMQ on Ubuntu Server

This script shows the installation of RabbitMQ on an Ubuntu server, ensuring all necessary dependencies and configurations are handled. It sets up the necessary repositories, installs Erlang, and finally installs RabbitMQ.

Install essential dependencies

sudo apt-get update -y
sudo apt-get install curl gnupg -y

Enable apt HTTPS Transport

In order for apt to be able to download RabbitMQ and Erlang packages from the Cloudsmith.io mirror or Launchpad, the apt-transport-https package must be installed:

sudo apt-get install apt-transport-https

Add Repository Signing Keys

In order to use the repositories, their signing keys must be added to the system. This will enable apt to trust packages signed by that key.

sudo apt-get install curl gnupg apt-transport-https -y

## Team RabbitMQ's main signing key
curl -1sLf "https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/com.rabbitmq.team.gpg > /dev/null
## Community mirror of Cloudsmith: modern Erlang repository
curl -1sLf https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key | sudo gpg --dearmor | sudo tee /usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg > /dev/null
## Community mirror of Cloudsmith: RabbitMQ repository
curl -1sLf https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key | sudo gpg --dearmor | sudo tee /usr/share/keyrings/rabbitmq.9F4587F226208342.gpg > /dev/null

Add Source List File

  • As with all 3rd party apt repositories, a file describing the RabbitMQ and Erlang package repositories must be placed under the /etc/apt/sources.list.d/ directory. /etc/apt/sources.list.d/rabbitmq.list is the recommended location
  • This command fetches the signing key for the RabbitMQ repository from a community mirror and adds it to the system keyrings.
  • To add the apt repository to the source list directory (under /etc/apt/sources.list.d), use:
sudo tee /etc/apt/sources.list.d/rabbitmq.list <<EOF
## Provides modern Erlang/OTP releases from a Cloudsmith mirror
##
deb [arch=amd64 signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu $distribution main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu $distribution main

# another mirror for redundancy
deb [arch=amd64 signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu $distribution main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu $distribution main

## Provides RabbitMQ from a Cloudsmith mirror
##
deb [arch=amd64 signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu $distribution main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu $distribution main

Another mirror for redundancy
deb [arch=amd64 signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu $distribution main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu $distribution main
EOF

Install Packages

  • After updating the list of apt sources, it is necessary to run apt-get update:
sudo apt-get update -y
  • Then install package with
## Install Erlang packages
sudo apt-get install -y erlang-base \
                        erlang-asn1 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

## Install rabbitmq-server and its dependencies
sudo apt-get install rabbitmq-server -y --fix-missing

Create RabbitMQ User

Add a New User

sudo rabbitmqctl add_user myuser mypassword

Set User Tags

sudo rabbitmqctl set_user_tags myuser administrator

Set Permissions for the User

sudo rabbitmqctl set_permissions -p / myuser ".*" ".*" ".*"

Managing the Service

To start and stop the server, use the systemctl tool. The service name is rabbitmq-server:

# stop the local node
sudo systemctl stop rabbitmq-server

# start it back
sudo systemctl start rabbitmq-server

# check on service status as observed by service manager
sudo systemctl status rabbitmq-server