dockerdocker-composerabbitmqdebianrabbitmqctl

RabbitMQ clustering: Can't join slave node to master


I have two RabbitMQ nodes using docker in different servers:

rabbitmq-1.myhost.com (master) rabbitmq-2.myhost.com (slave)

I try to join the slave to master creating a two node cluster with this:

root@rabbitmq-2:/#  rabbitmqctl stop_app
Stopping rabbit application on node rabbit@rabbitmq-2 ...
root@rabbitmq-2:/# rabbitmqctl join_cluster rabbit@rabbitmq-1.myhost.com

But I get:

root@rabbitmq-2:/# rabbitmqctl join_cluster rabbitmq-1.myhost.com
Clustering node rabbit@rabbitmq-2 with rabbitmq-1.myhost.com
Error:
{:badarg, [{:rpc, :rpcify_exception, 2, [file: 'rpc.erl', line: 467]}, {:rpc, :call, 5, [file: 'rpc.erl', line: 410]}, {:lists, :foldl, 3, [file: 'lists.erl', line: 1263]}, {:rabbit_mnesia, :discover_cluster, 1, [file: 'src/rabbit_mnesia.erl', line: 804]}, {:rabbit_mnesia, :join_cluster, 2, [file: 'src/rabbit_mnesia.erl', line: 236]}]}

Edit: I copy my /etc/hosts before adding the previous line:

root@rabbitmq-2:/# cat /etc/hosts

127.0.0.1localhost

::1 localhost ip6-localhost ip6-loopback

fe00::0 ip6-localnet

ff00::0 ip6-mcastprefix

ff02::1 ip6-allnodes

XX.XX.XX.XX rabbitmq-1.myhost.com rabbitmq-1

YY.YY.YY.YY rabbitmq-2.myhost.com rabbitmq-2

But I get this when I start my docker container:

Attaching to rabbitmq-2

rabbitmq-2 | 11:02:14.540 [error]

rabbitmq-2 |

rabbitmq-2 | BOOT FAILED

rabbitmq-2 | ===========

rabbitmq-2 | 11:02:14.542 [error] BOOT FAILED

rabbitmq-2 | 11:02:14.543 [error] ===========

rabbitmq-2 | 11:02:14.543 [error] ERROR: epmd error for host rabbitmq-2: address (cannot connect to host/port)

rabbitmq-2 | ERROR: epmd error for host rabbitmq-2: address (cannot connect to host/port)

Solution

  • I finally got it adding the two IPs with the alias (rabbitmq-1 and rabbitmq-2) to /etc/hosts and with these commands in slave node (rabbitmqctl-2):

    rabbitmqctl stop_app
    
    rabbitmqctl reset
    
    rabbitmqctl join_cluster rabbit@rabbitmq-1
    
    rabbitmqctl start_app
    
    rabbitmqctl cluster_status