问题描述
我正在尝试连接两个 Erlang 虚拟机(在 Centos 8 上运行,Erlang/OTP 23),一个位于 GCP us-east1-b 和另一个 GCP europe-west6,两者都在同一个 VPC 内,在不同的子网上运行,我们-east 10.33.0.0/16 eur-west on 10.88.0.0/16。 GCP 路由和防火墙应设置为允许跨这些子网和整个 VPC 的流量。 Ping 可以从 VM 到 VM(见下文)。 Telnet 适用于 erlang epmd 端口 4369。问题 - 当使用 erlang ping 实用程序 net_adm:ping()/1 将机器连接到机器时 - 返回“pang”,表示未连接。
对可能存在的问题有任何建议或想法,非常感谢!!!
这里是关于设置的其他研究和事实。
注意 - GCP 防火墙规则,注意测试连接上的 GCP 网络“阻塞”结果,并注意端口 35539 和 42257 的 TELNET 响应未连接(这可能解释了为什么 VM 返回“pang”或无法连接)
[g@app-server1-east ~]$ erl -name [email protected] -setcookie whale
Erlang/OTP 23 [erts-11.1.3] [source] [64-bit] [smp:2:2] [ds:2:2:10] [asy
nc-threads:1] [hipe]
Eshell V11.1.3 (abort with ^G)
([email protected])1> net_adm:ping('[email protected]').
pang
([email protected])2>
[g@app-server1-east ~]$ ping 10.88.0.2
PING 10.88.0.2 (10.88.0.2) 56(84) bytes of data.
64 bytes from 10.88.0.2: icmp_seq=1 ttl=64 time=105 ms
64 bytes from 10.88.0.2: icmp_seq=2 ttl=64 time=103 ms
64 bytes from 10.88.0.2: icmp_seq=3 ttl=64 time=104 ms
64 bytes from 10.88.0.2: icmp_seq=4 ttl=64 time=103 ms
64 bytes from 10.88.0.2: icmp_seq=5 ttl=64 time=103 ms
^C
--- 10.88.0.2 ping statistics ---
6 packets transmitted,5 received,16.6667% packet loss,time 12ms
rtt min/avg/max/mdev = 103.290/103.749/105.243/0.754 ms
[g@app-server1-east ~]$ epmd -names
epmd: up and running on port 4369 with data:
name ack1 at port 35539
[gbaird@app-server1-east ~]$ telnet 10.88.0.2 4369
Trying 10.88.0.2...
Connected to 10.88.0.2.
Escape character is '^]'.
exit
Connection closed by foreign host.
[g@app-server1-east ~]$ telnet 10.88.0.2 42257
Trying 10.88.0.2...
telnet: connect to address 10.88.0.2: Connection timed out here
[g@app-server2-eur ~]$ erl -name [email protected] -setcookie whale
Erlang/OTP 23 [erts-11.1.3] [source] [64-bit] [smp:2:2] [ds:2:2:10] [asyn
c-threads:1] [hipe]
Eshell V11.1.3 (abort with ^G)
([email protected])1> node
([email protected])1> .
node
([email protected])2>
g@app-server2-eur ~]$ ping 10.33.0.2
PING 10.33.0.2 (10.33.0.2) 56(84) bytes of data.
64 bytes from 10.33.0.2: icmp_seq=1 ttl=64 time=105 ms
64 bytes from 10.33.0.2: icmp_seq=2 ttl=64 time=103 ms
64 bytes from 10.33.0.2: icmp_seq=3 ttl=64 time=103 ms
64 bytes from 10.33.0.2: icmp_seq=4 ttl=64 time=103 ms
^C
--- 10.33.0.2 ping statistics ---
5 packets transmitted,4 received,20% packet loss,time 10ms
rtt min/avg/max/mdev = 103.194/103.601/104.685/0.666 ms
[g@app-server2-eur ~]$ epmd -names
epmd: up and running on port 4369 with data:
name ack2 at port 42257
[gbaird@app-server2-eur ~]$ telnet 10.33.0.2 4369
Trying 10.33.0.2...
Connected to 10.33.0.2.
Escape character is '^]'.
exit
Connection closed by foreign host.
[g@app-server2-eur ~]$ telnet 10.33.0.2 35539
Trying 10.33.0.2...
telnet: connect to address 10.33.0.2: Connection timed out
[gbaird@app-server2-eur ~]$
解决方法
Erlang 的 EPMD(Erlang Port Mapper Daemon)是监听 4369 端口的,但是节点监听的是随机端口。
在建立集群时,节点在本地主机的 EPMD 中注册其端口,并联系远程主机的 EPMD 查询远程节点的实际端口,然后流量直接转到该端口。 EPMD 不是中继。
您可以通过kernel configuration控制节点监听的端口范围,特别是inet_dist_listen_min
和inet_dist_listen_max
,允许它们在FW中