Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect two erlang nodes?

Tags:

erlang

Can someone give me more then one possibility to how to connect two Erlang nodes. I know one way using erlang:set_cookie/2 and curious if there is another way.

like image 614
erlang Avatar asked Dec 09 '16 01:12

erlang


People also ask

How do Erlang nodes communicate?

Erlang processes communicating by message passing between different machines. In this case, it's obvious that data must be copied from one computer to another.

What are Erlang nodes?

A node is an executing Erlang runtime system that has been given a name, using the command-line flag -name (long names) or -sname (short names). The format of the node name is an atom name@host. name is the name given by the user.


1 Answers

1. Use -setcookie.

You can also use -setcookie when erlang execute,

In first terminal of my local machine,

hyun@hyun-VirtualBox:~$ erl -sname a -setcookie guitar
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]

And second terminal of my local machine,

hyun@hyun-VirtualBox:~$ erl -sname b -setcookie guitar
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]

Lastly, in first terminal,

Eshell V7.0  (abort with ^G)
(a@hyun-VirtualBox)1> net_adm:ping('b@hyun-VirtualBox').
pong

2. Copy $HOME/.erlang.cookie

you can just copy $HOME/.erlang.cookie to other remote pc for sharing same cookie value.


Also, you have to think about security.

getting_started

An Erlang node is completely unprotected when running erlang:set_cookie(node(), nocookie). This can sometimes be appropriate for systems that are not normally networked, or for systems which are run for maintenance purposes only. Refer to auth(3) for details on the security system.

like image 113
hyun Avatar answered Sep 19 '22 18:09

hyun