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