Install RabbitMQ Server on Ubuntu 22.04|20.04|18.04
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.
https://googleads.g.doubleclick.net/pagead/ads?us_privacy=1—&client=ca-pub-5143258973069156&output=html&h=60&adk=2069393153&adf=174675478&w=468&lmt=1676547779&rafmt=12&channel=4973241802&format=468×60&url=https%3A%2F%2Fcomputingforgeeks.com%2Fhow-to-install-latest-rabbitmq-server-on-ubuntu-linux%2F&wgl=1&dt=1676547778628&bpp=1&bdt=863&idt=1186&shv=r20230213&mjsv=m202302090101&ptt=9&saldr=aa&abxe=1&cookie=ID%3D2cf0fd4caaee8c8a%3AT%3D1676547779%3AS%3DALNI_MZsjHcDR1pcPwavt4H5FJ91E5nWVw&gpic=UID%3D000009ebf452eb6f%3AT%3D1676547779%3ART%3D1676547779%3AS%3DALNI_Mac9cVvwX47wGc4znWPAta8ZpnFqw&correlator=7564744409369&frm=20&pv=2&ga_vid=1731927865.1676547778&ga_sid=1676547779&ga_hid=502178210&ga_fc=1&u_tz=-180&u_his=2&u_h=1080&u_w=1920&u_ah=1080&u_aw=1920&u_cd=24&u_sd=1&adx=540&ady=721&biw=1920&bih=995&scr_x=0&scr_y=358&eid=44759926%2C44759842%2C44759875%2C31072254&oid=2&pvsid=1069068647161234&tmod=1704695546&nvt=1&ref=https%3A%2F%2Fwww.google.com%2F&fc=896&brdim=1920%2C0%2C1920%2C0%2C1920%2C0%2C1920%2C1080%2C1920%2C995&vis=1&rsz=%7C%7CoeE%7C&abl=CS&pfx=0&fu=256&bc=31&ifi=1&uci=a!1&fsb=1&xpc=0DamDFvvto&p=https%3A//computingforgeeks.com&dtd=1192
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 22.04|20.04|18.04 LTS.
Step 1: Install Erlang/OTP
RabbitMQ requires Erlang to be installed first before it can run. Install Erlang on Ubuntu 22.04|20.04|18.04 system using our previous guide:
Once Erlang has been installed, proceed to step 2.
Step 2: Add RabbitMQ Repository to Ubuntu
Team RabbitMQ maintains an apt repository on PackageCloud, a package hosting service. It provides packages for most recent RabbitMQ releases.
Let’s add RabbitMQ Repository to our Ubuntu system.
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.deb.sh | sudo bash
Command execution output if successuful:
Detected operating system as Ubuntu/jammy.
Checking for curl...
Detected curl...
Checking for gpg...
Detected gpg...
Running apt-get update... done.
Installing apt-transport-https... done.
Installing /etc/apt/sources.list.d/rabbitmq_rabbitmq-server.list...done.
Importing packagecloud gpg key... done.
Running apt-get update... done.
The repository is setup! You can now install packages.
Step 3: Install RabbitMQ Server Ubuntu 22.04|20.04|18.04
To install RabbitMQ Server Ubuntu 22.04|20.04|18.04, update apt list first:
$ sudo apt update
Hit:1 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:2 https://download.docker.com/linux/ubuntu jammy InRelease
Hit:3 http://ke.archive.ubuntu.com/ubuntu jammy InRelease
Hit:4 http://ke.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:6 http://ke.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:5 https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu jammy InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
Then install rabbitmq-server
package:
sudo apt install rabbitmq-server
Hit the y key to start the installation.
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
socat
The following NEW packages will be installed:
rabbitmq-server soca
0 upgraded, 2 newly installed, 0 to remove and 27 not upgraded.
Need to get 12.3 MB of archives.
After this operation, 15.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
After installation, RabbitMQ service is started and enabled to start on boot. To check the status, run:
$ 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 Thu 2022-05-12 23:57:22 EAT; 40s ago
Main PID: 5631 (beam.smp)
Tasks: 28 (limit: 9460)
Memory: 95.0M
CPU: 3.177s
CGroup: /system.slice/rabbitmq-server.service
├─5631 /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 128000 -sbwt none -sbwtdcpu>
├─5642 erl_child_setup 32768
├─5672 /usr/lib/erlang/erts-12.2.1/bin/epmd -daemon
├─5699 inet_gethost 4
└─5700 inet_gethost 4
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]: Doc guides: https://rabbitmq.com/documentation.html
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]: Support: https://rabbitmq.com/contact.html
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]: Tutorials: https://rabbitmq.com/getstarted.html
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]: Monitoring: https://rabbitmq.com/monitoring.html
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]: Logs: /var/log/rabbitmq/rabbit@ubuntu22.log
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]: /var/log/rabbitmq/rabbit@ubuntu22_upgrade.log
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]: <stdout>
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]: Config file(s): (none)
Mei 12 23:57:22 ubuntu22 rabbitmq-server[5631]: Starting broker... completed with 0 plugins.
Mei 12 23:57:22 ubuntu22 systemd[1]: Started RabbitMQ broker.
You can confirm if the service is configured to start on boot using the command:
$ systemctl is-enabled rabbitmq-server.service
enabled
If it returns disabled, enable it by running:
sudo systemctl enable rabbitmq-server
Step 4: Enable the RabbitMQ Management Dashboard (Optional)
You can optionally enable the RabbitMQ Management Web dashboard for easy management.
$ sudo rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@ubuntu:
rabbitmq_management
The following plugins have been configured:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to rabbit@ubuntu...
The following plugins have been enabled:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
started 3 plugins.
The Web service should be listening on TCP port 15672
$ sudo ss -tunelp | grep 15672
tcp LISTEN 0 128 0.0.0.0:15672 0.0.0.0:* 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:
sudo rabbitmqctl add_user admin StrongPassword
sudo rabbitmqctl set_user_tags admin administrator
Login with this admin username and the password assigned.
Step 5: Set RabbitMQ Cluster (Optional)
If you need to achieve high availability and higher throughput, consider configuring RabbitMQ cluster on your Ubuntu 22.04|20.04|18.04 servers by following the guide below:
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:
To install RabbitMQ on CentOS 7 / CentOS 6 server, see: