Reputation: 4319
I am trying to setup a RabbitMQ cluster via DockerCloud, and sort of lost.
There are plenty of tutorials out there, but I cannot figure out how Docker Cloud is creating the clusters so I can deploy and connect two running RabbitMQ services?
What I have so far:
Now I don't know where to go from there.
Questions I have:
- How do I deploy two instances of RabbitMQ and link them together?
- If they are linked, how is Docker Cloud managing it? Or do I have to do this over the admin GUI?
Any guidance or pointing me in the right direction is highly appreciated.
Upvotes: 1
Views: 956
Reputation: 4319
Since I couldn't find a guide on how to set it up on Docker Cloud, here an explanation:
Dockerfile
FROM rabbitmq:3.5.3-management
MAINTAINER Dimitris Kapanidis [email protected]
COPY rabbitmq-cluster /usr/local/bin/
COPY pre-entrypoint.sh /
EXPOSE 5672 15672 25672 4369 9100 9101 9102 9103 9104 9105
ENTRYPOINT ["/pre-entrypoint.sh"]
CMD ["rabbitmq-cluster"]
The important part (especially for Docker Cloud) is the rabbitmq-cluster file:
#!/bin/bash
hostname=`hostname`
RABBITMQ_NODENAME=${RABBITMQ_NODENAME:-rabbit}
if [ -z "$CLUSTER_WITH" -o "$CLUSTER_WITH" = "$hostname" ]; then
echo "Running as single server"
rabbitmq-server
else
echo "Running as clustered server"
/usr/sbin/rabbitmq-server -detached
rabbitmqctl stop_app
echo "Joining cluster $CLUSTER_WITH"
rabbitmqctl join_cluster ${ENABLE_RAM:+--ram} $RABBITMQ_NODENAME@$CLUSTER_WITH
rabbitmqctl start_app
# Tail to keep the a foreground process active..
tail -f /var/log/rabbitmq/*
fi
In Docker Cloud, create a new service and search for harbur/rabbitmq-cluster
. When deploying the image, select "deploy on every node", and use tags to identify your cluster nodes.
In the environment variables, enter: CLUSTER_WITH: rabbitmq-cluster-1 (the name of your first instance) ERLANG_COOKIE: abcdefg
The rabbitmq-cluster script gets executed on every node (rabbit-mq-cluster-1, rabbit-mq-cluster-2 etc.), so the environment variable makes sure just to join those hosts which are not the first. This makes sure that you can scale via the Docker Cloud, and new nodes automatically gets clustered with your first node.
Upvotes: 1