This repository accompanies a blog article/YouTube video I created to walk people through the setup of a RabbitMQ cluster on their machine. Go to my website to learn more about the setup:
Set up a RabbitMQ cluster on your laptop using Docker
In this section you will learn the commands used to launch a RabbitMQ cluster using the regular docker engine run command.
- Start master node:
docker run -d \
--name="rabbit1" \
--hostname="rabbit1"\
-e RABBITMQ_ERLANG_COOKIE="secret string" \
-e RABBITMQ_NODENAME="rabbit1" \
--volume=(pwd)/rabbitmq.config:/etc/rabbitmq/rabbitmq.config \
--volume=(pwd)/definitions.json:/etc/rabbitmq/definitions.json \
--publish="4369:4369" \
--publish="5671:5671" \
--publish="5672:5672" \
--publish="15671:15671" \
--publish="15672:15672" \
--publish="25672:25672" \
rabbitmq:3-management- Start slave #1:
docker run -d \
--name="rabbit2" \
--hostname="rabbit2"\
-e RABBITMQ_ERLANG_COOKIE="secret string" \
-e RABBITMQ_NODENAME="rabbit2" \
--volume=(pwd)/rabbitmq.config:/etc/rabbitmq/rabbitmq.config \
--volume=(pwd)/definitions.json:/etc/rabbitmq/definitions.json \
--link="rabbit1:rabbit1" \
rabbitmq:3-management- Start slave #2:
docker run -d \
--name="rabbit3" \
--hostname="rabbit3"\
-e RABBITMQ_ERLANG_COOKIE="secret string" \
-e RABBITMQ_NODENAME="rabbit3" \
--volume=(pwd)/rabbitmq.config:/etc/rabbitmq/rabbitmq.config \
--volume=(pwd)/definitions.json:/etc/rabbitmq/definitions.json \
--link="rabbit1:rabbit1" \
--link="rabbit2:rabbit2" \
rabbitmq:3-management- View container logs individually
docker logs -f <rabbit#>This will display the logs for the chosen container, and follow them just like tail -f /log/path would do.
- Run producer / consumer
The producer / consumer scripts were created as simple Node.js scripts so they can be executed using regular bash script execution syntax.
This section details how to start the whole cluster using docker-compose and a YAML definition file
- Create a network shared by all containers
docker network create rabbitmq-cluster- Start cluster:
docker-compose up -d- View logs for all containers
docker-compose logs -f- Run producer / consumer for testing
Same as in the section detailing docker run you can launch the consumer/producer as regular shell scripts.
To be continued
To be continued
To be continued
Very useful tool for simulating message circulation in your RabbitMQ setup.