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 18.04, 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.

Set Hostname

You can start by configuring the hostname for your server.

Set server hostname on CentOS 6:

$ cat /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

Add EPEL repository:

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

sudo yum -y install epel-release

Add Erlang repository and install Erlang.

sudo rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
sudo yum install erlang

Add RabbitMQ Repository:

For CentOS 7:

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

For CentOS 6:

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

Install rabbitmq-server package.

sudo yum -y install rabbitmq-server

Start and enable rabbitmq-server to start on boot.

CentOS 7:

sudo systemctl enable&nbsp;--now rabbitmq-server

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

Enable RabbitMQ UI

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&nbsp;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:

raabitmq ui

Login with username and the password created earlier:

raabitmq dashboard

The next article to read is:

How to Backup and Restore RabbitMQ Data & Configurations

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here