1

第一的。Erlang 节点无法连接Erlang - Nodes don't identify没用。

我已经尝试了所有方法。

同一台机器没问题。但它在机器之间失败了。

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

曲奇饼

他们有相同的饼干。

防火墙

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

tcpdump

没有任何包裹。

4

1 回答 1

0

Linux is not responsible for service names, so this ping should fail:

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

This linux ping should succeed:

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

Erlang examples are often using functions called ping/pong that would use epmd and use @ synax.

This looks good if domains are setup correctly (though note '-' and '_' are not the same):

@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]

Hosts are just:

192.168.142.135  centos-1
192.168.142.136  centos-2

so the pear@centos-2 like lines you setup are not being used by erl. You can run as many erl shells as you like with different names and not need to update hosts.

Once that setup is working if you look in /etc/resolv.conf you should have a domain and it should be the same on both machines. If it is, you can try adding an alias with it to the hosts like this:

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

Though ideally the setup in resolv.conf is to a local dns server that set's this naming up so centos-1.example.com and centos-2.example.com can already ping each other.

于 2021-12-27T17:01:19.797 回答