Erl node startup Method
Short Name:
- Erl-sname name
- Erl-sname name @ shorthost
Longname:
- Erl-name
- Erl-name @ shorthost
- Erl-name @ fullhost
Note:
Name: Atom () | string () shorthost: Atom () | string (), cannot contain ".". For example, "myhost" fullhost: [shorthost ()] | IP address, such as "test.mydomain.com" and "8.34.135.3"
Short Name and long name are mainly in different formats. If the host in long name is a domain name, DNS resolution is required.
We can also add the following in hosts:
ip ShotHost
To enable the shortname Name node to support other hosts (refer to the introduction below)
Note
Note: The nodes of shot name and long name cannot communicate with each other.
Example
Short Name:
Assume that the local/etc/hosts configuration is 8.27.86.135 da6600.fb. joyent. Us.
Erl-sname Cheng% Started a node named Cheng @ da6600
Erl-name Cheng% Started a node named: cheng@da6600.fb.joyent.us
If the domain name is not specified in our local hosts configuration, We need to specify the Host:
Erl-sname Cheng @ da6600% Started a node named Cheng @ da6600
Long Name:
Erl-name Cheng @ da6600
Cheng@da6600.fb.joyent.us Erl-name
Cheng@8.27.86.135 Erl-name
Note that the three longname nodes are the same node.
Application
In many documents, the following steps are required for Distributed Program Development:
- Test A single node on the local machine,
- Multiple nodes in the local machine are tested,
- Test close to real environment on multiple hosts
Step 1 is usually usedErl-sname nameA similar method is used to generate a node. Therefore, it seems that sname can only be used on the local machine?
In general, shortname is limited to multiple nodes on the local machine. longname can span multiple hosts (through IP and DNS resolution ).
Of course, we can also use short name node like Long Name node. The difference is that long names can be resolved through DNS, while short names must be manually added to hosts. The purpose is to forward local requests to the target host.
Let's use short name to test it.
Server1 (IP: 8.27.86.135)
Start node:
erl -sname foo@server1
Server2 (server2 can also be in the Intranet, and the link can only be initiated by server2)
Add the following to/etc/hosts:
8.27.86.135 server1
Then start node:
erl -sname bar> net_kernel:connect_node('foo@server1').true> nodes().> [foo@server1]
In this way, the two nodes are connected.
Similarly, we can add an entry in server1, which is a shortname of server2 and then connect to it.
At this point, the use of short name and long name should be clear.
Reprinted: http://erlangdisplay.iteye.com/blog/321933