(Last Updated On: May 8, 2019)

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 18.04 LTS

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 mq-01.example.com

Set server hostname on CentOS 7:

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

sudo hostnamectl set-hostname mq-01.example.com --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.

wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
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 --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 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:

Login with username and the password created earlier:

The next article to read is:

How to Backup and Restore RabbitMQ Data & Configurations