Ali cloud modify the host name, hostname

A permanently modify the host name of the method (for ordinary server)

1, modified by the hostname command.

[root@izwz9f7pm0tw36neb1j7gmz ~]# hostname node1

After modifying the host name found or no change, you need to re-open a session or log on again

Note:

The effect of this command is to temporarily modify the host name linux, it's survival of the current linux running time, that the next
run time before the restart. General subsequent amendments take effect immediately, but this is only temporary force not permanent

2, / etc / sysconfig / network by modifying the configuration file.

[root@node1 ~]# cat /etc/sysconfig/network
# Created by anaconda
NETWORKING_IPV6=no
PEERNTP=no
GATEWAY=172.18.207.253

Add a HOSTNAME = node1 in this profile

[root@node1 ~]# vi /etc/sysconfig/network

Note: By modifying the contents of this profile, it is possible to achieve a permanent modification linux hostname, but it does not take effect immediately, that is not in the current run time to take effect, began to take effect after the next reboot, at least not in the current session to take effect, users need to exit and restart the server to take effect later. By modifying the configuration file, together with the hostname command, can be realized immediately and permanently modify the host name of linux.

After the restart the server finds the host name has not changed

Note: If CentOS 7 operating system, you can use the command: hostnamectl set-hostname hostname to modify, modified after re-login or restart SHELL server.

If Ubuntu system, you need to modify the file / etc / hostname, its corresponding host name changed to the new host name. See point 3.

3, modify the configuration file / etc / hosts

This role is to provide file and control the role of ip hostname, linux adoption of the document to know a ip corresponds to a host name, or domain name resolution effect. Such as for example google ip is 10.23.56.238, you can add the final line in this file:

10.23.56.238   google.com

This line corresponds to a control file, the format of each line is:

ip global hostname hostname another name

Check the configuration file, as follows:

Editor vi / etc / hosts configuration file to the server ip add a corresponding host name

Of course, this file can own the machine host name and ip put up, what role? Because some software to achieve the corresponding host name and ip, such as the oracle by this document. The feature set of its own documents of the machine, which is somewhat similar to windows on my computer right click Properties, and then set the host name as the computer name inside.

Guess you like

Origin www.cnblogs.com/liuzhiyun/p/11247321.html