AWS peer discovery and custom hostnames

242 views
Skip to first unread message

Alexander Shlygin

unread,
Feb 19, 2018, 8:29:03 AM2/19/18
to rabbitmq-users
AWS plugin returns privateDns field or ip address as hostname for discovered instances in cluster. PrivateDns always has ip-xx format. Is there any way to use own hostnames for instances discovered with AWS plugin? The best way I see is private ip name lookup instead of using privateDns fields.

Michael Klishin

unread,
Feb 19, 2018, 9:34:07 AM2/19/18
to rabbitm...@googlegroups.com
Private IP addresses and private DNS records are the only two options supported by AWS peer discovery.

There is a different implementation that's not AWS specific and can use preconfigured DNS A/AAAA records and reverse lookups for discovery
instead:

http://www.rabbitmq.com/cluster-formation.html#peer-discovery-dns

On Mon, Feb 19, 2018 at 4:29 PM, Alexander Shlygin <z.rest...@gmail.com> wrote:
AWS plugin returns privateDns field or ip address as hostname for discovered instances in cluster. PrivateDns always has ip-xx format. Is there any way to use own hostnames for instances discovered with AWS plugin? The best way I see is private ip name lookup instead of using privateDns fields.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Alexander Shlygin

unread,
Feb 19, 2018, 10:47:58 AM2/19/18
to rabbitmq-users
Yes, I understand that, but sometimes AWS discovery can be more flexible. At least we don't need to maintain DNS records in case of autoscaling events. Btw, what is the purpose of Private IP in discovered peers? In which situation rabbit@<ip> can be a valid nodename?

Mon, 19 февраля 2018 г., 17:34:07 UTC+3 пользователь Michael Klishin написал:
Private IP addresses and private DNS records are the only two options supported by AWS peer discovery.

There is a different implementation that's not AWS specific and can use preconfigured DNS A/AAAA records and reverse lookups for discovery
instead:

http://www.rabbitmq.com/cluster-formation.html#peer-discovery-dns
On Mon, Feb 19, 2018 at 4:29 PM, Alexander Shlygin <z.rest...@gmail.com> wrote:
AWS plugin returns privateDns field or ip address as hostname for discovered instances in cluster. PrivateDns always has ip-xx format. Is there any way to use own hostnames for instances discovered with AWS plugin? The best way I see is private ip name lookup instead of using privateDns fields.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Michael Klishin

unread,
Feb 19, 2018, 3:57:57 PM2/19/18
to rabbitm...@googlegroups.com
It is possible to use IP addresses in node names as long as they resolve
(and there's an entire runtime subsystem that allows you to tweak how
hostname resolution is done without touching /etc/hosts or DNS:
http://erlang.org/doc/apps/erts/inet_cfg.html).

Perhaps a custom inetrc file could help your case, if it was created on autoscaling
group member node on boot.

To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Alexander Shlygin

unread,
Feb 20, 2018, 5:02:54 AM2/20/18
to rabbitmq-users
Thanks a lot! That helped me. I believe I missed that part:
The lookup method string tries to parse the hostname as an IPv4 or IPv6 string and return the resulting IP address. It is automatically tried first when native is not in the Methods list. To skip it in this case, the pseudo lookup method nostring can be inserted anywhere in the Methods list.

понедельник, 19 февраля 2018 г., 23:57:57 UTC+3 пользователь Michael Klishin написал:

Michael Klishin

unread,
Feb 20, 2018, 5:20:16 AM2/20/18
to rabbitm...@googlegroups.com
So in other words, leaving out the native (the system resolver) mechanism would be sufficient
for your case.

That's a cool inetrc feature I haven't considered!

To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Sant

unread,
Jan 5, 2019, 8:07:15 AM1/5/19
to rabbitmq-users
Hi Michael, I'm using AWS peer discovery with Ec2 Tags but my problem is also the same. Since i'm using a custom hostname the autocluster always fails since it doesn't match with the nodename (which is the privatedns hostname) 

 I would like to use a custom hostname instead of the one PrivateDNS.

I'm trying to understand how the inetrc file  will solve this problem if the plugin gets the privatedns / privateip for the nodename. I'm trying something like below but it doesn't work

cat /var/lib/rabbitmq/.erl_inetrc 
%% specify lookup method
{lookup, [file, dns]}.

@Alexander  - It would be really helpful if you can share how you solved your problem 

Michael Klishin

unread,
Jan 5, 2019, 4:16:37 PM1/5/19
to rabbitm...@googlegroups.com
VM hostname can be done in a variety of ways that are not RabbitMQ-specific.
By far the easiest option is usually to go with the common deployment scenario and use private DNS record or private IP address that all EC2 instances have.

inetrc is useful when none of them are an option and you need specifically the Erlang VM to resolve a certain hostname even though local DNS resolve won’t be able to resolve it.

The hosts_file entry is the most convenient option [1] as it uses an external file in the same format as /etc/hosts, which is convenient to generate.

Santhosh Kumar

unread,
Jan 5, 2019, 9:25:32 PM1/5/19
to rabbitm...@googlegroups.com
Hi Michael - Thanks for getting back..The problem is not about setting the hostname on the VM.
The problem is the nodename that the aws peer discovery gets (it allows to use either privatedns  or privateip) doesn't match with the custom hostname we have on the ec2 instance and hence the auto cluster is not working..

My understanding is that the hostname and the nodename calculated by the aws peer discovery plugin should be the same. Please correct me if I'm wrong here.

Alexander Shlygin

unread,
Jan 10, 2019, 4:47:13 AM1/10/19
to rabbitmq-users
Hi Sant, as a result I used PrivateIP variant of nodenames. If {lookup, [file, dns]} is specified, then non-system resolver is used and names like 192.168.1.10 will resolve. That wasn't the best scenario in my case but it worked at least.

суббота, 5 января 2019 г., 17:07:15 UTC+4 пользователь Sant написал:

Santhosh Kumar

unread,
Jan 10, 2019, 4:56:54 AM1/10/19
to rabbitm...@googlegroups.com
Hi Alexander,  How about the hostname of your instances ? did you use a custom hostname or you used the  PrivateIP for that also ? 

Alexander Shlygin

unread,
Jan 11, 2019, 5:26:00 AM1/11/19
to rabbitmq-users
I've used such snippet in env file:
NODENAME=rabbit@`ip addr show eth0 | grep -oP 'inet \K((\d{1,3}.){1,3}\d{1,3})'`

четверг, 10 января 2019 г., 13:56:54 UTC+4 пользователь Sant написал:

Santhosh Kumar

unread,
Apr 10, 2019, 6:26:53 AM4/10/19
to rabbitm...@googlegroups.com
I used this in the env file 
USE_LONGNAME=true
NODENAME=rabbit@`hostname -i`

along with cluster_formation.aws.use_private_ip = true in the config file. By this way I didn't have to change my custom hostname and the auto discovery works without any issues.

Michael Klishin

unread,
Apr 23, 2019, 10:23:55 AM4/23/19
to rabbitmq-users
Thank you for reporting back. The setting above makes RabbitMQ use private IPs for hostnames.

Santhosh Kumar

unread,
May 8, 2019, 9:32:44 PM5/8/19
to rabbitm...@googlegroups.com
Hi Michael - it will make RabbitMQ to use private IPs for nodenames.  Ex: rab...@10.x.x.x  is nodename and  hostname for my machine  is like rabbitmq-node1.example.com
Reply all
Reply to author
Forward
0 new messages