I used the Linux command--to modify the host name

Source: Internet
Author: User

All of the following settings are tested in CentOS, and other Linux systems play the same way, except that the directory of the configuration files may be different.

The hostname in the LAN is similar to the domain name in the WAN, there are two ways to modify the host name:

(1) Modify host name in current session:

#hostname    // displays the host name of the current session #hostname XXX    // modifies the hostname, only works on the current session

(2) Modify the hostname in the configuration file:

The above method only works for the current session, restarts the system, and the hostname is back to its original name, so there must be a configuration file that records the host name. So modify this configuration file to modify the host name:

#vi/etc/sysconfig/network    // Modify the hostname configuration file

The above operation did complete the task of modifying the hostname, but the purpose of setting the hostname is to have the hostname like the domain name in the WAN, he can replace the IP address. So you also need to set up something like a domain name server in a wide area network, which is the configuration file that binds the hostname and IP address.

#vi/etc/hosts    // BIND host name and IP address

Add a line to this file:

192.168. 80.100    The Hadoop    // front IP address is the address of this machine, followed by the corresponding host name

Because we use the hostname in the configuration file in Hadoop, it is more stable than the IP address, so it is necessary to complete this binding.

In the Windows system also has a such configuration file, its address in C:\Windows\System32\drivers\etc\hosts, also can modify the contents of this file, to achieve different host name and IP address mapping.

I used the Linux command--to modify the host name

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.