Centos8 重启网卡

不能使用 service 和 systemctl

  • 方法:nmcli c reload +网卡名

    例:nmcli c reload eth0

  • 如果不行,可尝试以下命令

    1
    2
    3
    4
    5
    6
    7
    8
    9
    # 重载所有 ifcfg 或 route 到 connection(不会立即生效)
    nmcli c reload ifcfg-xxx
    # 重载指定 ifcfg 或 route 到 connection(不会立即生效)
    nmcli c load /etc/sysconfig/network-scripts/ifcfg-ethX
    nmcli c load /etc/sysconfig/network-scripts/route-ethX
    # 立即生效 connection,有 3 种方法
    nmcli c up ethX
    nmcli d reapply ethX
    nmcli d connect ethX
  • 重启主机后发现网卡不能开机自启,需要手动启动网卡:

    1
    nmcli connection modify ens33 connection.autoconnect yes

校准时间

  • centos8 之后:不在支持 ntpd 软件包,使用 chrony 配置 ntp 服务器用于同步时间

    • 他有二个程序 chrony(命令行界面程序)和 chronyd(守护进程)
    • 默认 centos8 安装系统后已经存在 chrony 的软件包了,可以通过 rpm -q chrony 确认是否存在,如果不存在使用 yum 安装即可: yum install chrony
  • chrony 本身既可以作为客户端向其他时间服务器同步时间又可以提供时间同步的服务, 配置文件统一都是:/etc/chrony.conf

  • Centos8 默认将 chrony 集成的系统中,并且自动启动. 只要设置好时区就能自动通过互联网修正你服务器的时间。

    1
    2
    3
    4
    5
    6
    7
    systemctl start chronyd.service
    systemctl status chronyd.service
    systemctl enable –now chronyd
    #设置时区
    timedatectl set-timezone "Asia/Shanghai"
    #重启 chronyd
    systemctl restart chronyd
  • 其他操作:修改时间同步服务 vim /etc/chrony.conf

    • 注释掉 #pool 2.centos.pool.ntp.org iburst

    • 加入新的时间服务器

      1
      2
      server 210.72.145.44 iburst
      server ntp.aliyun.com iburst