[erlang-questions] Automatic nodes discovering
Ciprian Dorin Craciun
ciprian.craciun@REDACTED
Sun Jun 17 17:10:11 CEST 2012
On Thu, Jun 7, 2012 at 2:06 PM, Maxim Treskin <zerthurd@REDACTED> wrote:
> Hello
>
> How I can make automatically discovering new nodes in cluster? When new node
> started up it is not listed in output of nodes() on other nodes without
> explicit ping of them. There is way to do this using RabbitMQ or ZeroMQ, but
> it is some redundant. Yet another way is ping of one known node in cluster,
> but it is constrained by nodes startup order.
>
> May be some interaction with epmd can helps?
>
> Thank you
We had exactly this problem. Thus we've implemented something
along these lines:
* in case you have multicast, each node sends an "advertisement"
on a well established group IP and port;
* in case you don't have multicast (as in EC2's case), each node
resolves a well known DNS A record and sends there an "advertisement"
over TCP to all resolved IP's; (we could have used UDP;)
The advertisement is actually an Erlang term in binary format,
which is authenticated with an HMAC with the cookie as the secret.
This way we are sure nobody tries to "join" if it doesn't know already
the cookie. (This advertiement is actually generic and could be used
for other things also.)
The code -- although experimental -- is open-source under Apache.
Unfortunately it's not factored into an independent project, but it
has few dependencies. (The TCP code isn't very efficient as for every
advertisement we make a new connection... It was done in a hurry.)
* https://github.com/cipriancraciun/mosaic-node/blob/development/applications/mosaic-node/sources/mosaic_discovery_agent_udp.erl
* https://github.com/cipriancraciun/mosaic-node/blob/development/applications/mosaic-node/sources/mosaic_discovery_agent_tcp.erl
* https://github.com/cipriancraciun/mosaic-node/blob/development/applications/mosaic-node/sources/mosaic_discovery_events.erl
See `start_discovery` for an example:
* https://github.com/cipriancraciun/mosaic-node/blob/development/applications/mosaic-node/sources/mosaic_node_app.erl
Hope it helps,
Ciprian.
P.S.: We use it together with `riak_core`, but it is not a dependency.
More information about the erlang-questions
mailing list