以centos7.5为例

1.修改主机名

[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# hostname k8s-node1 ##临时生效
localhost.localdomain
[root@localhost
~]# hostnamectl set-hostname k8s-node1 ##重启后永久生效 [root@localhost ~]# reboot

重启后

Last login: Tue Apr  2 16:00:30 2019
[root@k8s-node1 ~]# hostname
k8s-node1
[root@k8s-node1 ~]# cat /etc/hostname
k8s-node1
[root@k8s-node1 ~]# hostnamectl
   Static hostname: k8s-node1
         Icon name: computer-vm
           Chassis: vm
        Machine ID: a5a43f5916c643bf83d6f99425a4b9d2
           Boot ID: 0043950ecb374652aebb84e6b8f05fa6
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-957.el7.x86_64
      Architecture: x86-64
[root@k8s-node1 ~]# 

修改ip

[root@k8s-node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33 
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=bf3736be-2267-4535-a658-39d7482dfabd
DEVICE=ens33
#ONBOOT=no


ONBOOT=yes
DNS1=192.168.111.2
IPADDR=192.168.111.131
PREFIX=24
GATEWAY=192.168.111.2
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
[root@k8s-node1 ~]# 
[root@k8s-node1 ~]# 
[root@k8s-node1 ~]# service network restart
Restarting network (via systemctl):  [  确定  ]
[root@k8s-node1 ~]# 

 

转载于:https://www.cnblogs.com/pu20065226/p/10643334.html

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐