First, start four cmd
-erl-sname A-setcookie ABC
-erl-sname B-setcookie ABC
-erl-sname C-setcookie ABC
-erl-sname D-setcookie EFG
Second, the node interconnection
1 nodes/0% get all node 2 with current node connection
Tests can be entered in the order of red numbers
1. Under a enter net_adm:ping (b), when a is connected to B, the return of Pong indicates success,
You can enter nodes () in a, you can see the node cluster that the current node is connected to [[email protected]],
You can enter nodes () in B to see the node cluster that the current node is connected to [[email protected]],
2. Under a enter net_adm:ping (c), when a connects to C, the return of Pong indicates success,
At this time
In a input nodes (), you can see the node cluster that the current node is connected to [[email protected],[email protected]],
In B input nodes (), you can see the node cluster that the current node is connected to [[email protected],[email protected]],
In C input nodes (), you can see the node cluster that the current node is connected to [[email protected],[email protected]],
Description: Erlang uses an all-connected approach by default, and when any node joins a cluster, all nodes within that cluster are already connected to each other
3. When a connection to the D node is returned Pang indicates a failure, because the a node and the B node use different cookies, to establish a connection, you must use the same cookie
PS: If you want to add the D node to the cluster, you need to modify the cookie value of the D node, you can use AUTH:SET_COOKIE/1 to modify the current node cookie, use AUTH:GET_COOKIE/1 to get the current node cookie
When D modifies a cookie, it can be successfully added to the cluster
Summary command:
Erl-sname Name% Build a node
Erl-sname name-setcookie value% establish a cookie value of node
NET_ADM:PING/1%ping A node Pong connection Pang table failed
Auth:get_cookie/1% Gets the current node cookie value
Auth:set_cookie/1% modifies the current node's cookie value (the connection is not broken and the other node is connected)
Auth:set_cookie/2% The first parameter is another node (node and cookie are atomic) The second parameter is that node's cookie is used to allow two node connections of different cookies
Erlang Cluster Testing