首页 > 解决方案 > 在谷歌云平台(GCP)上连接 Erlang/Elixir VM 节点的问题,相同的 VPC - 不同的区域,MNESIA 无法复制

问题描述

我正在尝试连接两个 Erlang 虚拟机(在 Centos 8、Erlang/OTP 23 上运行),一个位于 GCP us-east1-b 和其他 GCP europe-west6 上,都在同一个 VPC 内,在不同的子网上运行,us-east 10.33 .0.0/16 eur-west 于 10.88.0.0/16。GCP 路由和防火墙应设置为允许跨这些子网和整个 VPC 的流量。Ping 从 VM 工作到 VM(见下文)。Telnet 适用于 erlang epmd 端口 4369。 ISSUE - 当使用 erlang ping 实用程序 net_adm:ping()/1 将机器连接到机器时 - 返回“pang”,表示未连接。

任何关于可能是什么问题的建议或想法,非常感谢!

这是有关设置的其他研究和事实。

注意 - GCP 防火墙规则,注意测试连接上的 GCP 网络“阻塞”结果,并注意端口 35539 ​​和 42257 的 TELNET 响应未连接(这可能解释了为什么虚拟机返回“pang”或不能连接)

[g@app-server1-east ~]$ erl -name ack1@10.33.0.2 -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)
(ack1@10.33.0.2)1> net_adm:ping('ack2@10.88.0.2').
pang
(ack1@10.33.0.2)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 ack2@10.88.0.2 -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)
(ack2@10.88.0.2)1> node 
(ack2@10.88.0.2)1> .
node
(ack2@10.88.0.2)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 ~]$ 

在此处输入图像描述

在此处输入图像描述

标签: google-cloud-platformerlangmnesiagoogle-cloud-networkinggoogle-vpc

解决方案


Erlang 的 EPMD(Erlang Port Mapper Daemon)是监听 4369 端口的那个,但节点监听的是随机端口。

建立集群时,节点在本地主机的 EPMD 中注册它的端口并联系远程主机的 EPMD 以查询远程节点的实际端口,然后流量直接进入该端口。EPMD 不是继电器。

您可以通过内核配置控制节点侦听的端口范围,特别是使用inet_dist_listen_minand inet_dist_listen_max,允许它们在 FW 中。


推荐阅读