[erlang-questions] Two network interfaces.

Michael Santos michael.santos@REDACTED
Tue Sep 13 18:14:10 CEST 2011


On Tue, Sep 13, 2011 at 03:25:42PM +0200, Krzysztof Blachowski wrote:
> Hi all. 
> 
> Let's imagine that we have two machines A and B with erlang VM. 
> 
> On each erlang machine there is application which uses mnesia database. The database is replicated between nodes.
> Each node has two interfaces "I1" which is extremely fast and "I2" which is slow. There is also a bunch of erlang nodes which are clients
> for A and B nodes and they are using native erlang interface.
> 
> I was trying to configure erlang nodes A and B to utilize this two interfaces but without any effect. 
> How to connect nodes A i B with fast link (for mnesia replication) and at this same time connect them with slow link with external clients?
> 
> I've tried:
> 
> 
> machine A:
> 
> erl -name master -setcookie secret
> 
> inet:getif():
> {ok,[{{192,168,1,10},{192,168,255,255},{255,255,0,0}},
>      {{10,132,24,10},{10,132,25,255},{255,255,254,0}},
>      {{127,0,0,1},{0,0,0,0},{255,0,0,0}}]}
> 
> machine B:
> 
> erl -name replica -setcookie secret
> 
> net_adm:ping('master@REDACTED'): 
> pong
> 
> net_adm:ping('master@REDACTED'):
> pang
> 
> Why? What I'm doing wrong?

Since the name of the node is 'master@REDACTED', it won't respond to
'master@REDACTED'.

What might work is changing the DNS resolution on either the clients or
the hosts. If the interfaces are mapped as follows:

I1: 192.168.1.10
I2: 10.132.24.10

The clients will do a DNS lookup on 'my.domain' and get 10.132.24.10. On
the mnesia nodes, force the resolution to the fast interface by adding
an entry to the /etc/hosts file:

192.168.1.10  my.domain

Or if you don't want to change the name lookup for everything on the
host, you can set it just for Erlang, something like:

cat<<EOF>erl_inetrc
{host, {192,168,1,10}, ["my.domain"]}.
{lookup, [file, dns]}.
EOF

The run:

erl -name master -kernel inetrc '"erl_inetrc"'

It's all explained here: http://www.erlang.org/doc/apps/erts/inet_cfg.html



More information about the erlang-questions mailing list