Last active
October 8, 2022 15:55
-
-
Save Pliner/46730aec1f90b6d0ecf7f24d61aae79f to your computer and use it in GitHub Desktop.
Runs 5 nodes rabbitmq cluster locally in docker-compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
rabbit_1: &rmq | |
image: rabbitmq:management | |
hostname: rabbit_1 | |
ports: | |
- "15673:15672" | |
- "5673:5672" | |
environment: | |
- RABBITMQ_ERLANG_COOKIE='mysecret' | |
healthcheck: | |
test: rabbitmq-diagnostics -q ping | |
interval: 10s | |
timeout: 5s | |
retries: 5 | |
rabbit_2: | |
<<: *rmq | |
hostname: rabbit_2 | |
ports: | |
- "15674:15672" | |
- "5674:5672" | |
rabbit_3: | |
<<: *rmq | |
hostname: rabbit_3 | |
ports: | |
- "15675:15672" | |
- "5675:5672" | |
rabbit_4: | |
<<: *rmq | |
hostname: rabbit_4 | |
ports: | |
- "15676:15672" | |
- "5676:5672" | |
rabbit_5: | |
<<: *rmq | |
hostname: rabbit_5 | |
ports: | |
- "15677:15672" | |
- "5677:5672" | |
rabbit_cluster: | |
image: rabbitmq:management | |
hostname: rabbit_cluster | |
depends_on: | |
rabbit_1: | |
condition: service_healthy | |
rabbit_2: | |
condition: service_healthy | |
rabbit_3: | |
condition: service_healthy | |
rabbit_4: | |
condition: service_healthy | |
rabbit_5: | |
condition: service_healthy | |
environment: | |
- RABBITMQ_ERLANG_COOKIE='mysecret' | |
command: | |
- /bin/sh | |
- -c | |
- | | |
echo "Waiting 20s to ensure the nodes initialized" | |
sleep 20 | |
echo "Joining rabbit_2 to rabbit_1" | |
rabbitmqctl -n rabbit@rabbit_2 stop_app | |
rabbitmqctl -n rabbit@rabbit_2 join_cluster rabbit@rabbit_1 | |
rabbitmqctl -n rabbit@rabbit_2 start_app | |
echo "Joining rabbit_3 to rabbit_1" | |
rabbitmqctl -n rabbit@rabbit_3 stop_app | |
rabbitmqctl -n rabbit@rabbit_3 join_cluster rabbit@rabbit_1 | |
rabbitmqctl -n rabbit@rabbit_3 start_app | |
echo "Joining rabbit_4 to rabbit_1" | |
rabbitmqctl -n rabbit@rabbit_4 stop_app | |
rabbitmqctl -n rabbit@rabbit_4 join_cluster rabbit@rabbit_1 | |
rabbitmqctl -n rabbit@rabbit_4 start_app | |
echo "Joining rabbit_5 to rabbit_1" | |
rabbitmqctl -n rabbit@rabbit_5 stop_app | |
rabbitmqctl -n rabbit@rabbit_5 join_cluster rabbit@rabbit_1 | |
rabbitmqctl -n rabbit@rabbit_5 start_app |
foobarbazmeow
commented
Oct 8, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment