How To Install RabbitMQ on CentOS 7 / CentOS 6

Posted on 23 views

This guide will cover the steps required to Install RabbitMQ on CentOS 7 / CentOS 6 server. My Lab is based on my previous guide Using Vagrant with Libvirt on Linux. RabbitMQ is a message broker software that implements AMQP (Advanced Message Queuing Protocol).

For Ubuntu, check: How to install Latest RabbitMQ Server on Ubuntu

Installation Requirements:

  1. EPEL repository
  2. Erlang repository
  3. RabbitMQ repository

I prefer using repositories to install the Rabbitmq server and Erlang as opposed to using rpm packages which tends to bring package dependency issues and having to manually update packages.

Step 1: Set System Hostname

You can start by configuring the hostname for your server.

Set server hostname on CentOS 6:

$ sudo vi /etc/sysconfig/network

Restart network service once you make the changes.

sudo /etc/init.d/network restart

Then confirm current hostname setting:

$ hostname

To temporarily set the hostname for the current shell session, use:

sudo hostname

Set server hostname on CentOS 7:

For CentOS 7 server, you can easily set server hostname using a hostnamectl command.

sudo hostnamectl set-hostname --static

Step 2: Add EPEL repository to CentOS 7/6 System

Add epel repository to your system using yum command as below:

sudo yum -y install epel-release wget

You can check the repository has been added and working using the following command:

sudo yum repolist

Step 3: Install Erlang on CentOS 7 / CentOS 6

Add Erlang official YUM repository:

sudo rpm -Uvh erlang-solutions-2.0-1.noarch.rpm

Then install Erlang RPM package:

sudo yum install erlang

Accept installation prompt and import GPG key:

Transaction Summary
Install  1 Package (+91 Dependent packages)

Total download size: 62 M
Installed size: 163 M
Is this ok [y/d/N]: y

Total                                                                                                                                                                  16 MB/s |  62 MB  00:00:03
Retrieving key from file:///etc/pki/rpm-gpg//erlang_solutions.asc
Importing GPG key 0xA14F4FCA:
 Userid     : "Erlang Solutions Ltd. "
 Fingerprint: 4349 75bd 900c cbe4 f7ee 1b1e d208 507c a14f 4fca
 Package    : erlang-solutions-2.0-1.noarch (installed)
 From       : /etc/pki/rpm-gpg//erlang_solutions.asc
Is this ok [y/N]: y

Confirm Erlang installation by checking the version and CLI tool access

$ erl
Erlang/OTP 24 [erts-12.0.3] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]

Eshell V12.0.3  (abort with ^G)
BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
       (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution

Step 4: Install RabbitMQ on CentOS 7 / CentOS 6

Add RabbitMQ Repository:

Run the commands below to add RabbitMQ YUM repository to yourCentOS 7 / CentOS 6:

cat << EOF | sudo tee /etc/yum.repos.d/rabbitmq.repo

Update repositories cache

sudo yum clean all
sudo yum makecache

List available repositories as configured in the system:

$ sudo yum repolist
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * updates:
repo id                                                                                  repo name                                                                                              status
base/7/x86_64                                                                            CentOS-7 - Base                                                                                        10072
droplet-agent/x86_64                                                                     DigitalOcean Droplet Agent                                                                                 5
epel/x86_64                                                                              Extra Packages for Enterprise Linux 7 - x86_64                                                         13665
erlang-solutions/7/x86_64                                                                Centos 7 - x86_64 - Erlang Solutions                                                                    5704
extras/7/x86_64                                                                          CentOS-7 - Extras                                                                                        500
rabbitmq_rabbitmq-server/7/x86_64                                                        rabbitmq_rabbitmq-server                                                                                  78
updates/7/x86_64                                                                         CentOS-7 - Updates                                                                                      2747
repolist: 32771

Install rabbitmq-server package.

sudo yum -y install rabbitmq-server

Start and enable rabbitmq-server to start on boot.

CentOS 7:

sudo systemctl enable --now rabbitmq-server

Check service status:

$ systemctl status rabbitmq-server
 rabbitmq-server.service - RabbitMQ broker
   Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-09-13 09:19:14 UTC; 48s ago
 Main PID: 9636 (beam.smp)
   CGroup: /system.slice/rabbitmq-server.service
           ├─9636 /usr/lib64/erlang/erts-12.0.3/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 -sbwtdc...
           ├─9651 erl_child_setup 32768
           ├─9676 /usr/lib64/erlang/erts-12.0.3/bin/epmd -daemon
           ├─9699 inet_gethost 4
           └─9700 inet_gethost 4

Sep 13 09:19:06 centos rabbitmq-server[9636]: Doc guides:
Sep 13 09:19:06 centos rabbitmq-server[9636]: Support:
Sep 13 09:19:06 centos rabbitmq-server[9636]: Tutorials:
Sep 13 09:19:06 centos rabbitmq-server[9636]: Monitoring:
Sep 13 09:19:06 centos rabbitmq-server[9636]: Logs: /var/log/rabbitmq/[email protected]
Sep 13 09:19:06 centos rabbitmq-server[9636]: /var/log/rabbitmq/[email protected]_upgrade.log
Sep 13 09:19:06 centos rabbitmq-server[9636]: 
Sep 13 09:19:06 centos rabbitmq-server[9636]: Config file(s): (none)
Sep 13 09:19:14 centos rabbitmq-server[9636]: Starting broker... completed with 0 plugins.
Sep 13 09:19:14 centos systemd[1]: Started RabbitMQ broker.

CentOS 6:

Use the commands below to start the service on CentOS 6:

sudo chkconfig rabbitmq-server on
sudo chkconfig --list | grep rabbitmq
sudo service rabbitmq-server start

To use RabbitMQ, add user first. By default, only guest user exists and he can connect from localhost.

$ rabbitmqctl add_user admin NUaiMe0k
Adding user "admin" ...

$ rabbitmqctl set_user_tags admin administrator
$ rabbitmqctl list_users
Listing users ...
admin [administrator]
guest [administrator]

Other rabbitmqctl administration commands are:

Delete User:

rabbitmqctl delete_user user

Change User Password:

rabbitmqctl change_password user strongpassword

Add virtualhost:

rabbitmqctl add_vhost /my_vhost

List virtualhosts:

rabbitmqctl list_vhosts

Delete virtualhost:

rabbitmqctl delete_vhost /my_vhost

Grant user permissions for vhost:

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

List vhost permissions:

rabbitmqctl list_permissions -p /my_vhost

To list user permissions:

rabbitmqctl list_user_permissions user

Delete user permissions:

rabbitmqctl clear_permissions -p /my_vhost user

Step 5: Enable RabbitMQ UI on CentOS 7 / CentOS 6

You can enable the Management Plugin to use a web-based interface to administer RabbitMQ.

### For CentOS 7 ###
sudo rabbitmq-plugins enable rabbitmq_management
sudo systemctl restart rabbitmq-server

### For CentOS 6 ###
sudo service rabbitmq-server restart

Configure Firewall

Open ports on the firewall:

sudo firewall-cmd --add-port=4369/tcp,25672/tcp --permanent

With Iptables:

sudo iptables -A INPUT -p tcp -m tcp --dport 4369 -j ACCEPT
sudo iptables -A INPUT -p tcp -m tcp --dport 25672 -j ACCEPT

Access RabbitMQ Admin web console

Access to the “http://server:15672/” from a client: You should get a login window:

install-rabbitmq-ubuntu-18.04-dashboard-min-1024x461 (1)

Login with username and the password created earlier:


The next article to read is:



Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.