使用腾讯云的服务器,然后我需要修改/etc/hosts文件部署集群服务,一打开/etc/hosts文件便如以下:
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.redhat.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
# /etc/cloud/cloud.cfg or cloud-config from user-data
#
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 VM_0_12_centos VM_0_12_centos
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4
# The following lines are desirable for IPv6 capable hosts
::1 VM_0_12_centos VM_0_12_centos
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
修改方式和常规的直接修改方式的不一样,直接对/etc/hosts文件进行修改,比如直接添加 127.0.0.1 wangshuai.tech 到/etc/hosts ,保存后虽然ping wangshuai.techt可以通,但是重启系统后添加的记录就消失了。
文件注释说,我的系统配置了manage_etc_hosts为True,如果要修改hosts的话
a. 需要先对/etc/cloud/templates/hosts.redhat.tmpl进行修改,
b. 然后修改或删除manage_etc_hosts的值在/etc/cloud/cloud.cfg文件中。
第一步,修改/etc/cloud/templates/hosts.redhat.tmpl文件
直接添加你要在/etc/hosts文件中出现的文件内容:
127.0.0.1 wangshuai.tech
关于第二步,修改manage_etc_hosts的值,在/etc/cloud/cloud.cfg文件中没有找到,那就忘掉吧。
最后reboot重启你的机器生效。
本人踩坑。亲测有效。