Build a Two Node Cluster

How do we join two nodes together in a single cluster?

Start the first node "lasp1".

If your Erlang system is configured to use only fully qualified host names, then in both of the following commands, replace "@localhost" with "@`hostname`"
where "hostname" is surrounded by backticks.

$ ./rebar3 shell --apps lasp --name [email protected]

Start the second node "lasp2".

$ ./rebar3 shell --apps lasp --name [email protected]

Then, get the second node's network information.

([email protected])1> partisan_peer_service_manager:myself().
#{name => [email protected], listen_addrs => [#{ip => {127,0,0,1}, port => 56699}]}

Then, join the first node to the second node.

([email protected])2> lasp_peer_service:join(#{name => [email protected], listen_addrs => [#{ip => {127,0,0,1}, port => 56699}]}).

=PROGRESS REPORT==== 20-Apr-2017::11:59:14 ===
          supervisor: {local,inet_gethost_native_sup}
             started: [{pid,<0.376.0>},{mfa,{inet_gethost_native,init,[[]]}}]

=PROGRESS REPORT==== 20-Apr-2017::11:59:14 ===
          supervisor: {local,kernel_safe_sup}
             started: [{pid,<0.375.0>},
                       {id,inet_gethost_native_sup},
                       {mfargs,{inet_gethost_native,start_link,[]}},
                       {restart_type,temporary},
                       {shutdown,1000},
                       {child_type,worker}]
ok
([email protected])3> 11:59:14.891 [info] Join ACCEPTED with #{name => [email protected], listen_addrs => [#{ip => {127,0,0,1}, port => 56699}]}; node is undefined and we are undefined: we have 2 members in our view.

Did this page help you?