RabbitMQ is a robust message broker widely used in distributed systems. This guide provides a detailed, step-by-step tutorial on installing RabbitMQ 3.10.8 with Erlang 25.2.3 on Debian 12 and configuring a Master-Slave cluster. The setup will involve two servers: a Master at 10.11.33.83 and a Slave at 10.11.33.93.

1. Configure Hostname Resolution

Ensure both servers can resolve each other’s hostnames by editing /etc/hosts.

On both Master and Slave servers, add the following lines to /etc/hosts:

Save and exit the file.

Verify the hostname resolution by running:

2. Install Required Dependencies

Update the package list and install necessary dependencies:

3. Install Erlang 25.2.3

RabbitMQ requires Erlang. Install version 25.2.3 by adding the RabbitMQ package repository.

Verify installation:

4. Install RabbitMQ 3.10.8

Add the RabbitMQ repository:

Enable and start RabbitMQ:

Check RabbitMQ status:

5. Configure RabbitMQ Environment

Set RabbitMQ to use long hostnames and define a fixed node name.

On Master (10.11.33.83):

Add:

Save and exit.

On Slave (10.11.33.93):

Add:

Save and exit.

Restart RabbitMQ on both servers:

Verify the node name:

6. Set Erlang Cookie for Clustering

Ensure the Erlang cookie is the same on both servers:

Restart RabbitMQ:

7. Enable RabbitMQ Management Plugin

Enable the RabbitMQ management plugin to monitor the cluster:

Access the RabbitMQ web UI at:

Default credentials:

  • Username: guest
  • Password: guest

8. Configure Cluster (Master-Slave)

Ensure RabbitMQ is running on the Slave before attempting to stop the application:

Stop RabbitMQ application on the Slave server:

Join the Slave node to the Master:

Check the cluster status:

9. Configure RabbitMQ Cluster in /etc/rabbitmq/rabbitmq.conf

By default, RabbitMQ does not create /etc/rabbitmq/rabbitmq.conf, so you must create it manually:

Add the following lines to define the cluster settings:

Save the file and restart RabbitMQ on both servers:

Verify the configuration:

10. Set a High Availability Policy

On the Master node, apply an HA policy:

Verify policies:

11. Test the Cluster Setup

On Master, create a test queue:

Check queues on both Master and Slave:

12. Simulate Failover

To test failover, stop RabbitMQ on the Master:

Publish a message from the Slave:

Restart the Master and verify the message persists:

Leave A Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.