Getting two erl shells to talk on OS X

▼魔方 西西 提交于 2019-12-01 17:16:42

It's kind of broken on the mac. By default, the mac can't resolve its own shortname. Your host's name is really probably "elife.local".

If you start erl with -name FQDN, then the pings will work.

ie: you would start it with

$ erl -name foo@elife.local

this probably could be fixed by making the mac capable of resolving it's own short name

Here's example output from my mac. When I do -sname I get the same result as you.

The first node:

$ erl -name foo@mookie.local
Erlang R13B03 (erts-5.7.4) [source] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false]

Eshell V5.7.4  (abort with ^G)
(foo@mookie.local)1> 

The other node:

$ erl -name bar@mookie.local
Erlang R13B03 (erts-5.7.4) [source] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false]

Eshell V5.7.4  (abort with ^G)
(bar@mookie.local)1> net_adm:ping('foo@mookie.local').
pong

A simpler fix might just be editing your /etc/hosts file and make sure you have something like this line:

127.0.0.1 localhost elife

My mac works fine with shortnames, and I believe this is what did it.

For the nodes communicate with each other, both should have the same cookie. On the same box it works as it end up using the cookie from $HOME/.erlang.cookie file. If this file is not present, it create a new file and put some random cookie in it. Future shells use the same cookie. But it is always better to specify the cookie on the command line via setcookie parameter.

erl -name node1@foo.local -setcookie mycookie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!