【发布时间】:2022-01-25 23:35:03
【问题描述】:
首先。 Erlang nodes failed to connect 和 Erlang - 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