Operations 6 min read

How to Deploy a High‑Availability RabbitMQ Cluster on CentOS 7

This guide walks through preparing three CentOS 7 nodes, installing Erlang and RabbitMQ, configuring users and permissions, setting environment variables, enabling the management plugin, synchronizing erlang.cookie, joining nodes in RAM or disc mode, and verifying cluster status via the web UI.

Open Source Linux
Open Source Linux
Open Source Linux
How to Deploy a High‑Availability RabbitMQ Cluster on CentOS 7

RabbitMQ Cluster Deployment

Preparation

Step 1: Three Linux systems (CentOS 7.3)

Hostname

IP Address

node1

192.168.137.138

node2

192.168.137.139

node3

192.168.137.140

## All node operations: host name resolution
# vim /etc/hosts
...
192.168.137.139  node2
192.168.137.140  node3
192.168.137.138  node1
...
# node1 operations: password‑less login to other hosts
ssh-keygen
ssh-copy-id node2
ssh-copy-id node3

Deploy RabbitMQ Cluster

Step 1: Install packages

# Install Erlang and RabbitMQ on all nodes
yum install -y erlang rabbitmq-server.noarch
systemctl start rabbitmq-server.service
systemctl status rabbitmq-server.service
systemctl enable rabbitmq-server.service

Step 2: Optional checks

# Check port 5672 (RabbitMQ default)
ss -ntl | grep 5672
# Main configuration file directory
/etc/rabbitmq/rabbitmq.config

Step 3: Add an OpenStack user with password RABBIT_PASS and grant administrator rights

rabbitmqctl add_user openstack RABBIT_PASS
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
rabbitmqctl set_user_tags openstack administrator

Step 4: Edit the RabbitMQ environment file

vim /etc/rabbitmq/rabbitmq-env.conf
...
RABBITMQ_NODE_PORT=5672
ulimit -S -n 4096
RABBITMQ_SERVER_ERL_ARGS="+K true +A30 +P 1048576 -kernel inet_default_connect_options [{nodelay,true},{raw,6,18,<<5000:64/native>>}] -kernel inet_default_listen_options [{raw,6,18,<<5000:64/native>>}]"
RABBITMQ_NODE_IP_ADDRESS=172.16.254.60
...

Step 5: Copy the environment file to the other two nodes and adjust the IP address accordingly

scp /etc/rabbitmq/rabbitmq-env.conf node2:/etc/rabbitmq/
scp /etc/rabbitmq/rabbitmq-env.conf node3:/etc/rabbitmq/
# Edit the file on each node to set the correct IP

Step 6: Enable the RabbitMQ management web UI

# List available plugins
/usr/lib/rabbitmq/bin/rabbitmq-plugins list
# Enable management plugin
/usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management mochiweb webmachine rabbitmq_web_dispatch amqp_client rabbitmq_management_agent
# or simply
rabbitmq-plugins enable rabbitmq_management
systemctl restart rabbitmq-server.service
systemctl status rabbitmq-server.service

Step 7: Distribute the .erlang.cookie file from node1 to the other nodes

rabbitmqctl status
scp /var/lib/rabbitmq/.erlang.cookie node2:/var/lib/rabbitmq/.erlang.cookie
scp /var/lib/rabbitmq/.erlang.cookie node3:/var/lib/rabbitmq/.erlang.cookie

Step 8: On node2 and node3, stop the application and join the cluster as RAM nodes, then restart

systemctl restart rabbitmq-server.service
rabbitmqctl stop_app
rabbitmqctl join_cluster --ram rabbit@node1
rabbitmqctl start_app

Step 9: Verify cluster status rabbitmqctl cluster_status Step 10: Access the management UI at

http://192.168.137.138:15672
RabbitMQ management UI screenshot
RabbitMQ management UI screenshot

Other Command Operations

Change default guest password to admin

rabbitmqctl change_password guest admin

Add an administrator user

rabbitmqctl add_user mqadmin mqadmin
rabbitmqctl set_user_tags mqadmin administrator
rabbitmqctl set_permissions -p / mqadmin ".*" ".*" ".*"

Change node type (disc or ram)

rabbitmqctl stop_app
rabbitmqctl change_cluster_node_type disc   # or ram
rabbitmqctl start_app

Remove a node from the cluster or reset a node

rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app
rabbitmqctl cluster_status

Forget a specific node from the cluster

rabbitmqctl forget_cluster_node rabbit@node3
rabbitmqctl reset
rabbitmqctl start_app
rabbitmqctl cluster_status

Official rabbitmqctl documentation

https://www.rabbitmq.com/rabbitmqctl.8.html

RabbitMQ documentation screenshot
RabbitMQ documentation screenshot
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxMessage QueueRabbitMQClusterCentOS
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.