Modify the Host Name of centos (Do not spray), and change the Host Name of centos
1. Temporarily modify the Host Name
Show Host Name:
Spark @ master :~ $ Hostname
Master
Modify host name:
Spark @ master :~ $ Sudo hostname hadoop
Spark @ master :~ $ Hostname
Hadoop
PS: the above changes are only temporary changes, and the changes are restored after the restart.
2. Change the host name permanently.
Permanent modification on redhat/centos
[Root @ localhost ~] # Cat/etc/sysconfig/network
NETWORKING = yes
HOSTNAME = localhost. localdomain
GATEWAY = 192.168.10.1
Modify the HOSTNAME of the network. The host name is located at the beginning and the domain name is located at the end. The host name is ignored.
[Root @ localhost ~] # Vi/etc/sysconfig/network
NETWORKING = yes
NETWORKING_IPV6 = no
HOSTNAME = master
This is a permanent modification and takes effect after restart. I do not know how to take effect immediately.
To take effect immediately, you can use the first method at the same time.
Another change is:
/Etc/hosts
127.0.0.1 localhost. localdomain
The part after 127.0.0.1.
Modify on deb/ubuntu:
Hostname
Localhost. localdomain
Sudo vi/etc/hostname
Enter hostname as master in/etc/hostname
Spark @ localhost :~ $ Cat/etc/hostname
Localhost
After the restart, the prompt is changed.
Spark @ master :~ $
If you do not want to restart, use the hostname command.
3. Other modification methods
Use sysctl to modify kernel. hostname
View:
Spark @ master :~ $ Sysctl kernel. hostname
Kernel. hostname = master
Modify:
Spark @ master :~ $ Sudo sysctl kernel. hostname = hadoop
Kernel. hostname = hadoop
Re-open the shell and change it to the following hostname: hadoop
Spark @ master :~ $