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.
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 node3Deploy 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.serviceStep 2: Optional checks
# Check port 5672 (RabbitMQ default)
ss -ntl | grep 5672
# Main configuration file directory
/etc/rabbitmq/rabbitmq.configStep 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 administratorStep 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 IPStep 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.serviceStep 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.cookieStep 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_appStep 9: Verify cluster status rabbitmqctl cluster_status Step 10: Access the management UI at
http://192.168.137.138:15672Other Command Operations
Change default guest password to admin
rabbitmqctl change_password guest adminAdd 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_appRemove a node from the cluster or reset a node
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app
rabbitmqctl cluster_statusForget a specific node from the cluster
rabbitmqctl forget_cluster_node rabbit@node3
rabbitmqctl reset
rabbitmqctl start_app
rabbitmqctl cluster_statusOfficial rabbitmqctl documentation
https://www.rabbitmq.com/rabbitmqctl.8.html
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
