【问题标题】:Erlang nodes failed to connect each otherErlang 节点无法相互连接
【发布时间】:2022-01-25 23:35:03
【问题描述】:

首先。 Erlang nodes failed to connectErlang - Nodes don't recognize 没用。

各种方法我都试过了。

同一台机器没问题。但是机器之间却失败了。

test@centos-1:~$ ping apple@centos-1 -c 1
PING apple@centos-1 (192.168.142.135) 56(84) bytes of data.
64 bytes from apple@centos-1 (192.168.142.135): icmp_seq=1 ttl=64 time=0.036 ms

test@centos-1:~$ ping pear@centos-2 -c 1
PING pear@centos-2 (192.168.142.136) 56(84) bytes of data.
64 bytes from pear@centos-2 (192.168.142.136): icmp_seq=1 ttl=64 time=0.292 ms

apple@centos-1 开始

@centos-1:~$ erl -sname apple@centos_1 -kernel inet_dist_listen_min 6369 inet_dist_listen_max 7369 -setcookie CKYBWKWCWNLSPZWSLJXT
Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit]

Eshell V12.2  (abort with ^G)
(apple@centos_1)1>

pear@centos-2 开始

test@centos-2:~$ erl -sname pear@centos-2 -kernel inet_dist_listen_min 6369 inet_dist_listen_max 7369 -setcookie CKYBWKWCWNLSPZWSLJXT
Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit]

Eshell V12.2  (abort with ^G)
(pear@centos-2)1>

连接失败

test@centos-1:~$ erl -sname apple@centos_1 -kernel inet_dist_listen_min 6369 inet_dist_listen_max 7369 -setcookie CKYBWKWCWNLSPZWSLJXT
Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit]

Eshell V12.2  (abort with ^G)
(apple@centos_1)1> net
net           net_adm       net_kernel
(apple@centos_1)1> net_kernel:connect_node('pear@centos-2').
false
(apple@centos_1)2>

我已经检查了我发现的所有情况

主机文件

192.168.142.135  apple@centos-1
192.168.142.136  pear@centos-2

cookie

他们有相同的cookie。

防火墙

firewall-cmd --add-port=6000-8000/tcp --permanent

tcpdump

没有任何包。

【问题讨论】:

  • 主要通信是 epmd TCP 端口 4369,它用于发现这些进程在您分配的范围内选择的端口。
  • stackoverflow.com/a/35769392/1269466 对我来说似乎是正确的答案,它会显示防火墙 cmd 中缺少的端口 4369。
  • 我已经检查过了,它也不起作用。@centos-2:~$ epmd -names epmd: up and running on port 4369 with data: name orange at port 6369
  • 我使用 -name 而不是 -sname。然后就可以了。
  • 这些 apple@ 和 pear@ 名称应该用于 erl 服务,而不是您的主机配置的一部分,epmd 的目的是回答这些名称的端口查找。为了 sname 工作/ etc/resolv.conf 应该在主机和 centos-1 中具有相同的域。[域名] 必须真正解析为 192.168.142.135 等。

标签: erlang erlang-otp epmd


【解决方案1】:

Linux 不对服务名称负责,所以这个 ping 应该会失败:

test@centos-1:~$ ping apple@centos-1 -c 1

这个 linux ping 应该成功:

test@centos-1:~$ ping centos-1 -c 1

Erlang 示例通常使用称为 ping/pong 的函数,这些函数将使用 epmd 和 @ synax。

如果域设置正确,这看起来不错(尽管注意“-”和“_”不一样):

@centos-1:~$ erl -sname apple@centos-1 -kernel inet_dist_listen_min 6369 inet_dist_listen_max 7369 -setcookie CKYBWKWCWNLSPZWSLJXT Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit]

主机只是:

192.168.142.135  centos-1
192.168.142.136  centos-2

所以你设置的 pear@centos-2 之类的行没有被 erl 使用。您可以使用不同的名称运行任意数量的 erl shell,而无需更新主机。

如果您在 /etc/resolv.conf 中查看该设置正常工作,您应该有一个域,并且在两台机器上应该是相同的。如果是,您可以尝试向主机添加一个别名,如下所示:

192.168.142.135  centos-1 centos-1.example.com
192.168.142.136  centos-2 centos-2.example.com

虽然理想情况下,resolv.conf 中的设置是到一个本地 dns 服务器,该服务器设置了这个命名,所以 centos-1.example.com 和 centos-2.example.com 已经可以相互 ping 通了。

【讨论】:

    猜你喜欢
    • 2014-06-28
    • 1970-01-01
    • 2011-03-29
    • 2019-07-19
    • 2011-04-11
    • 2017-12-16
    • 2013-04-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多