The RabbitMQ clustering document
https://www.rabbitmq.com/clustering.html
describes a process whereby you can deploy a configuration file for clustering so that a cluster is automatically created when your rabbitmq nodes boot.eg
[{rabbit,
[{cluster_nodes, {['rabbit@rabbit1', 'rabbit@rabbit2', 'rabbit@rabbit3'], ram}}]}].
You apply this file on each of the 3 nodes at /etc/rabbitmq/rabbitmq.config, and then start rabbitmq on each and a cluster will apparently form.
This doesn't appear to work too well eg
If you start rabbit2, and rabbit3 hasn't already come up, the service will not start on rabbit2, as it is trying to create a cluster with rabbit3.
Equally, if you only apply the config on rabbit1, and have pre-started rabbit2 and rabbit3, rabbit1 will form a cluster with rabbit2 only, as, according to the documentation (I don't understand why):
RabbitMQ will try to cluster to each node provided, and stop after it can cluster with one of them.
The only way this seems to work is if you apply the config file on all 3 nodes, and have them start at exactly the same time. I am trying to deploy this with Ansible, which creates the nodes sequentially, so that doesn't work.
What am I missing here?
I also deploy RabbitMQ clusters with Puppet, and you actually don't have to spin up all nodes at the exactly the same time.
What I usually do, and has so far worked for me is:
.
nodes we're clustering together (because I don't want to rely on DNS being available) * deploy rabbitmq.config
.
To create erlang cookie, I usually use http://passwordsgenerator.net/ and set it up to create 20 character string consistent only of uppercase characters. Then, put this string into /var/lib/rabbitmq/.erlang.cookie, like this:
This should work for you. Tested on 3.2, 3.3 and 3.5 versions.
I've made some progress on this.
The issue appears to relate to the choice of using ram nodes rather than disc nodes in the rabbitmq.config file. From the documentation:
When I change the config file to use "disc" instead of "ram", cluster creation was a lot more stable.