1:修改hostname
vi /etc/hostname
修改成你想要的名字即可
2:修改hosts
[root@ycloud2-test-s3 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
在後面增加Ip hostname即可
修改後需要重啓網絡設置
1:重啓服務器
2:使用命令重啓網絡設置
[root@v2x-preprod-service-ecs-02 ~]# service network restart
或者命令
[root@v2x-preprod-service-ecs-02 ~]# /etc/init.d/network restart
如果啓動網絡設置出現如下錯誤
Restarting network (via systemctl): Job for network.service failed because the control
process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.
[FAILED]
查看網絡狀態
[root@v2x-preprod-service-ecs-02 network-scripts]# systemctl status network