0
0
RabbitMQdevops~30 mins

RabbitMQ cluster formation - Mini Project: Build & Apply

Choose your learning style9 modes available
RabbitMQ cluster formation
📖 Scenario: You are setting up a RabbitMQ cluster to ensure high availability and load balancing for your messaging system. This project will guide you through creating a simple RabbitMQ cluster with two nodes on the same machine using Docker containers.
🎯 Goal: Build a RabbitMQ cluster with two nodes named rabbit1 and rabbit2. Configure rabbit2 to join the cluster with rabbit1 as the initial node.
📋 What You'll Learn
Create two RabbitMQ Docker containers named rabbit1 and rabbit2.
Configure rabbit2 to join the cluster with rabbit1.
Verify the cluster status showing both nodes.
💡 Why This Matters
🌍 Real World
RabbitMQ clusters are used in real systems to ensure messaging services stay available even if one server fails.
💼 Career
Understanding how to form and manage RabbitMQ clusters is important for DevOps roles managing messaging infrastructure.
Progress0 / 4 steps
1
Create the first RabbitMQ node container
Run a Docker container named rabbit1 using the official RabbitMQ image with management plugin enabled. Use the command docker run -d --hostname rabbit1 --name rabbit1 rabbitmq:3-management.
RabbitMQ
Need a hint?

Use docker run -d --hostname rabbit1 --name rabbit1 rabbitmq:3-management to start the first node.

2
Create the second RabbitMQ node container
Run a Docker container named rabbit2 with hostname rabbit2 using the same RabbitMQ image. Use the command docker run -d --hostname rabbit2 --name rabbit2 --link rabbit1 rabbitmq:3-management.
RabbitMQ
Need a hint?

Use docker run -d --hostname rabbit2 --name rabbit2 --link rabbit1 rabbitmq:3-management to start the second node.

3
Join the second node to the cluster
Use docker exec to run the command rabbitmqctl stop_app inside rabbit2. Then run rabbitmqctl join_cluster rabbit@rabbit1 inside rabbit2. Finally, run rabbitmqctl start_app inside rabbit2 to start the node as part of the cluster.
RabbitMQ
Need a hint?

Use docker exec rabbit2 rabbitmqctl stop_app, then docker exec rabbit2 rabbitmqctl join_cluster rabbit@rabbit1, and finally docker exec rabbit2 rabbitmqctl start_app.

4
Verify the cluster status
Run docker exec rabbit1 rabbitmqctl cluster_status to display the cluster nodes and verify that both rabbit1 and rabbit2 are listed.
RabbitMQ
Need a hint?

Run docker exec rabbit1 rabbitmqctl cluster_status and look for both nodes in the output.