简体   繁体   English

Erlang:自动填充.hosts.erlang文件?

[英]Erlang: automatic population of .hosts.erlang file?

I am using net_adm:world() to connect to Nodes on other hosts, but the only way I got this to work is once I manually created a hosts file and list the name of the other host in the file. 我正在使用net_adm:world()连接到其他主机上的节点,但是我实现这一点的唯一方法是手动创建主机文件并列出文件中其他主机的名称。 If I had 10 hosts I would have to put this file on all ten machines and update the list ten times every time a new host is added to the cluster. 如果我有10台主机,我必须将此文件放在所有10台机器上,并在每次将新主机添加到群集时将列表更新十次。

Is there no way this file can be automatically updated each time a connection to a Node on a new host is made? 每次与新主机上的节点建立连接时,是否无法自动更新此文件?

your .hosts.erlang file doesn't need to be complete or 100% correct. 您的.hosts.erlang文件不需要完整或100%正确。 a node only needs to connect to one other to learn about every other node in the cluster. 节点只需要相互连接即可了解群集中的每个其他节点。

you could skip maintaining the .hosts.erlang file and use mutlicast UDP to dynamically discover nodes. 您可以跳过维护.hosts.erlang文件并使用mutlicast UDP动态发现节点。 See nodefinder for example code. 有关示例代码,请参见nodefinder

we started down the multicast UDP route but then decided to just maintain a central hosts file and use rsync to distribute it to all hosts. 我们开始了多播UDP路由,但后来决定只维护一个中央主机文件并使用rsync将其分发给所有主机。 we restart nodes infrequently so it hasn't been a big problem. 我们不经常重启节点,所以它不是一个大问题。

We use chef to prepopulate the .hosts.erlang file for nodes that belong to a cluster. 我们使用chef来为属于集群的节点预填充.hosts.erlang文件。 The function net_adm:world() can be used to determine the nodes that are currently part of a cluster which does not necessarily match what is contained .hosts.erlang , eg, when one of the nodes is down. 函数net_adm:world()可用于确定当前属于集群的节点,该节点不一定与包含.hosts.erlang的节点匹配,例如,当其中一个节点关闭时。 An alternative to using net_adm:world() is the function net_adm:world_list(Hosts) which takes a list of hosts (instead of reading from .hosts.erlang ) and does the same as net_adm:world() to determine the currently connected nodes. 使用net_adm:world()的替代方法是net_adm:world_list(Hosts)函数,它接受主机列表(而不是从.hosts.erlang读取)并与net_adm:world()执行相同net_adm:world()以确定当前连接的节点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM