When you modify the host name, you can directly use the tools provided by the system.
[root@localhost centos]# hostnamectl
Static hostname: localhost.localdomain
Icon name: computer-vm
Chassis: vm
Machine ID: 89bf177f78dc49f6b4954e1e9511e267
Boot ID: 8f46edc8b7b648f58d5d4c1f3c15cbee
Virtualization: vmware
Operating System: CentOS Linux 8
CPE OS Name: cpe:/o:centos:centos:8
Kernel: Linux 4.18.0-240.10.1.el8_3.x86_64
Architecture: x86-64
[root@localhost centos]# sudo hostnamectl set-hostname k8s-slave
[root@localhost centos]# hostnamectl
Static hostname: k8s-slave
Icon name: computer-vm
Chassis: vm
Machine ID: 89bf177f78dc49f6b4954e1e9511e267
Boot ID: 8f46edc8b7b648f58d5d4c1f3c15cbee
Virtualization: vmware
Operating System: CentOS Linux 8
CPE OS Name: cpe:/o:centos:centos:8
Kernel: Linux 4.18.0-240.10.1.el8_3.x86_64
Architecture: x86-64
[root@localhost centos]# cat /etc/hostname
k8s-slave
[root@localhost centos]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@localhost centos]# vi /etc/hosts
[root@localhost centos]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.187.151 k8s-slave
[root@localhost centos]#
Read More:
- VirtualBox + CentOS 7 virtual machine setting static IP address of host only NIC
- A solution to the default invalid host only mode of CentOS virtual machine in VirtualBox
- [Solved] Centos7 Wget Error: nown. wget: unable to resolve host address ‘mirrors.aliyun.com’
- Encapsulation of adding, deleting and modifying database by JDBC
- Modifying the default style of scrollbar in Android
- Modifying SVN user name and password in eclipse
- Idea method of modifying git account and password
- SSH Login: RSA host key for 192.168.x.x has changed and you have requested strict checking. Host key
- Method of modifying file and folder permission by Chmod command in Linux
- Methods of modifying index and columns names by dataframe in pandas
- Spring boot thymeleaf crud implements simple functions of adding, deleting, modifying and querying
- Prompt SQL server error 15023 solution memo when modifying user mapping
- Centos7 installing Kafka
- TNS-12545: Connect failed because target host or object does not exist
- VMware this host does not support 64 bit solutions
- [MySQL] [serialize] [error record] after modifying data, no data will be returned (in fact, MySQL does not support it)
- Sudo: unable to resolve host solution
- After modifying the Tomcat configuration file in development, the modified configuration file will be automatically restored after ecplise starts Tomcat
- KVM–Host does not support any virtualization…
- ValueError: check_ hostname requires server_ The solution record of the host name