1, before change
[root@localhost ~]# hostname
localhost.localdomain
2, execute the following command on the command line (Node01 is the hostname of the newly set)
hostnamectl set-hostname Node01
[root@localhost ~]# hostname
node01
[root@localhost ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 # # :: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6 # comment out the top two lines of the original host name, we use can not be changed after the completion of hostnamectl change / etc / hosts file folder here need to manually change 127.0.0.1 node01
Restart the host, to see whether the changes to take effect
[root@node01 ~]# reboot
[root@localhost ~]# hostname
node01