节点命名问题

问题描述 投票:0回答:1

有两台机器:M1具有两个IP地址192.168.5.47、192.168.1.250。以及IP地址为192.168.5.250的M2。

我在M1上启动一个erlang节点:

nik@nik-PC:~/erlsrc/test_mk$ erl -name '[email protected]' -setcookie cook
Erlang/OTP 22 [erts-10.6.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

Eshell V10.6.2  (abort with ^G)
([email protected])1> 

然后,我在M2上建立另一个节点并尝试ping M1:

nik2@nik2-PC:~$ erl -name '[email protected]' -setcookie cook
Erlang/OTP 22 [erts-10.6.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

Eshell V10.6.2  (abort with ^G)
([email protected])1> 
([email protected])1> net_adm:ping('[email protected]').
pang
([email protected])2> 

如果其中一个具有多个IP地址并以'name @ localhost'或'[email protected]'启动,如何在远程计算机上的节点之间进行通信?还是最好使用域名?

erlang otp
1个回答
0
投票

如果节点在一个LAN网络中运行但在另一台计算机上运行,​​则可以尝试在每台计算机上检测IP,例如,运行:

$ hostname -I

让我们假设机器1具有IP 192.168.5.47,而机器2具有IP 192.168.5.250。现在您需要在带有标志namemachine 1上运行节点,其中包含IP-machine#1

$ erl -name '[email protected]' -setcookie cook

现在在machine 2中执行相同的操作,但是使用machine 2-machine#2

的IP
$ erl -name '[email protected]' -setcookie cook

现在您可以尝试将ping[email protected]发送到[email protected]-计算机#1

([email protected])1> net_adm:ping('[email protected]').
pong
© www.soinside.com 2019 - 2024. All rights reserved.