This error occurs because the host name and/etc/hosts file are inconsistent. You only need to write the host name and its IP address to the/etc/hosts file and then OK.
Note that the name cannot contain underscores.
In addition to modifying the network file, run the hostname command to specify the host name, so you do not need to restart the OS.
1. Modify the/etc/sysconfig/network File
[Root @ localhost ~] # Cat/etc/sysconfig/network
NETWORKING = yes
NETWORKING_IPV6 = no
HOSTNAME = shark
2. Use the hostname command to modify the host name. The modification and restart will fail, but we have modified it in the first step. So it does not matter if it fails.
[Root @ localhost ~] # Hostname
Localhost
[Root @ localhost ~] # Hostname shark
[Root @ localhost ~] # Hostname
Dave
3. Modify the hosts file
[Root @ localhost ~] # Cat/etc/hosts
# Do not remove the following line, orvarious programs
# That require network functionality willfail.
127.0.0.1 localhost
192.168.7.2 shark