在启动时动态设置节点名 [英] Setting node name dynamically at boot time

查看:138
本文介绍了在启动时动态设置节点名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用relx构建我的发行版,我不能使用默认的 -sname someuser@127.0.0.1
相反,我想做一些像-sname someuser @`hostname -i`这样的东西来在引导时定义节点的公共IP。使用 -sname someuser @ hostname -i``不起作用,因为 hostname -i 未扩展到真正的IP 。我尝试使用net_kernel:start(xxxxxxx)但是没有起作用。

I am building my release using relx and I can not use the default -sname someuser@127.0.0.1. Instead I would like to do something like -sname someuser@`hostname -i` to define the node's public IP at boot time. Using -sname someuser@hostname -i`` does not work because hostname -i is not expanded to a real IP. I tried to use net_kernel:start(xxxxxxx) but it did not work.

有没有办法获取动态的 -sname 在vm.args中使用relx?

Is there any way to get a dynamic -sname in vm.args using relx ?

感谢:)

推荐答案

文档(并在的评论中回答) @Soup d'Campbells ), -sname -name 标志不需要主机名,并将自动将节点ID的主机部分添加到主机的sid(短名称不满足-sname,FQDN为-name):

As written in the documentation (and answered in the comments by @Soup d'Campbells), the -sname and -name flags do not need the hostname, and will automatically fill the Host part of the node's ID with the host'sid (short not fully qualified for -sname, FQDN for -name):


-sname 名称使Erlang运行时系统进入分布式节点,类似于-name,但节点名称的主机名部分Name @ Host
将是短名称,不能完全限定。

-sname Name Makes the Erlang runtime system into a distributed node, similar to -name, but the host name portion of the node name Name@Host will be the short name, not fully qualified.

这有时是运行分布式Erlang的唯一方法,如果DNS
域名系统) 没有运行。在使用-sname标志运行的节点和使用
-name标志运行的节点之间不能有任何通信
,因为节点名称在分布式Erlang系统中必须是唯一的。

This is sometimes the only way to run distributed Erlang if the DNS (Domain Name System) is not running. There can be no communication between nodes running with the -sname flag and those running with the -name flag, as node names must be unique in distributed Erlang systems.

-name 名称使Erlang运行时系统成为分布式节点。该标志调用节点所需的所有网络服务器成为
分发。请参见net_kernel(3)。还确保epmd在Erlang启动之前在当前主机上的
上运行。请参阅epmd(1)。

-name Name Makes the Erlang runtime system into a distributed node. This flag invokes all network servers necessary for a node to become distributed. See net_kernel(3). It is also ensured that epmd runs on the current host before Erlang is started. See epmd(1).

节点的名称将是Name @ Host,其中Host是当前主机的完全
限定主机名。对于短名称,请改用
-sname标志。

The name of the node will be Name@Host, where Host is the fully qualified host name of the current host. For short names, use the -sname flag instead.

如果您打算使用分布式节点,在您的域中使用DNS,使用 -name 标志,因为它还将调用所有必需的网络服务器(如上所述)。

If you plan to use a distributed node, and you do have DNS in your domain, use the -name flag, as it will also invoke all necessary network servers (just as written above).

为自己看:

$> erl -sname bouly
(bouly@myserver)1>

$> erl -name bouly
(bouly@myserver.myhome.net)1>

这篇关于在启动时动态设置节点名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆