Erlang node short names and long names

Source: Internet
Author: User
Tags joyent
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:

  1. Test A single node on the local machine,
  2. Multiple nodes in the local machine are tested,
  3. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.