[erlang-questions] use inetrc to add entries to perceived /etc/hosts

Michael Santos michael.santos@REDACTED
Tue Oct 4 15:28:23 CEST 2011


On Tue, Oct 04, 2011 at 02:14:45PM +0200, Philip Müller wrote:
> Hi everybody,
> 
> we are working on a distributed erlang project. We want to have as
> little dependencies on specific infrastructure as possible.
> 
> This is why we assume that
> 
> 1. There is no DNS server running providing a naming service.
> 2. Entries in /etc/hosts on the node hosts are insufficient to
> provide naming for all other node hosts.
> 
> We need to make it possible for all hosts to reach each other and to
> start all nodes from a central host. We could start all nodes via
> ssh, identifying hosts via IP addresses, but as we understand it
> slave:start/1 is made for this job and only works with hostnames.
> 
> Searching for a solution we stumbled across "-kernel inetrc". The
> idea is to scp an inetrc to all hosts and then start nodes with
> slave:start and get them to read their local inetrc on startup.
> 
> We tried starting a node locally with the following command:
> 
> >erl -rsh ssh -sname test -kernel inetrc '"./erl_inetrc"'
> 
> For the contents of erl_inetrc we tried the following two solutions,
> but didn't get it to work.
> Running slave:start(host1). on host2 always gave the following error:
> >{error,timeout}
> But a simple "ssh 192.168.2.100" works.
> 
> 1. everything in erl_inetrc
> 
> erl_inetrc:
> >{host, {192,168,2,100}, ["host1"]}.
> >{host, {192,168,2,101}, ["host2"]}.
> 
> 2. an additional hosts file
> 
> erl_inetrc:
> >{file, hosts, "./hosts"}.
> 
> hosts file:
> >192.168.2.100 host1
> >192.168.2.101 host2
> 
> Any ideas what we did wrong?

Try enforcing the lookup order. Add this to the "erl_inetrc" file:

{lookup, [file, dns]}.



More information about the erlang-questions mailing list