aweber / rabbitmq-autocluster

This project is now maintained by the RabbitMQ Team, visit the official repo @
https://github.com/rabbitmq/rabbitmq-autocluster
BSD 3-Clause "New" or "Revised" License
336 stars 120 forks source link

RabbitMQ should support running with "rabbit@IP" long-name #147

Closed fiksn closed 7 years ago

fiksn commented 7 years ago

We are running RabbitMQ on Kubernetes. For clustering I tried rabbitmq-autocluster plugin with Etcd2. It would be great if Erlang distribution directly used IP. The latest discussion about this topic I found is http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2009-December/005650.html

Based on that I came up with:

sed -i '/RABBITMQ_USE_LONGNAME/iRABBITMQ_NODENAME="$RABBITMQ_NODENAME -name test$$@${RABBITMQ_NODENAME##*@}"' /usr/lib/rabbitmq/lib/rabbitmq_server-${RABBITMQ_VERSION}/sbin/rabbitmqctl ; sed -i '/start_rabbitmq_server() {/iRABBITMQ_NAME_TYPE="-name"' /usr/lib/rabbitmq/lib/rabbitmq_server-${RABBITMQ_VERSION}/sbin/rabbitmq-server

then I also do export RABBITMQ_NODENAME="rabbit@$(hostname -i)" before starting "rabbitmq-server". (Note that I don't set RABBITMQ_USE_LONGNAME at all, with it it doesn't work)

With RabbitMQ 3.6.0 that trick worked fine, but not in later 3.6 versions. I can workaround by using rabbit_cli.beam from 3.6.0 with a later version. This hack is in use for development but I wouldn't really dare to run it in production.

I believe https://github.com/rabbitmq/rabbitmq-server/blob/master/src/rabbit_cli.erl#L183 is not really fine. What I mean is: i'd expect when RABBITMQ_NODENAME and RABBITMQ_USE_LONGNAME are set, RabbitMQ should use those settings. If RABBITMQ_NODENAME is not set or not a FQDN it can still fall back to old logic.

In my case I don't really want to use DNS for inter-cluster communication, but as far as I understand it also wouldn't work if I did (due to the ".no-domain" addendum).

Thanks for your help.

fiksn commented 7 years ago

Err, i wanted to submit this to rabbitmq of course, sorry about the mistake. Just a cross-link if anyone will find it interesting https://github.com/rabbitmq/rabbitmq-server/issues/1182