on  It Road.com

在 RHEL 7 上启用 NTP 服务的步骤:

禁用chronyd服务

要停止 chronyd,请以 root 身份发出以下命令:

# systemctl stop chronyd

要防止 chronyd 在系统启动时自动启动,请以 root 身份发出以下命令:

# systemctl disable chronyd

使用yum安装ntp:

# yum install ntp

然后启用并启动ntpd服务:

# systemctl enable ntpd.service
# systemctl start ntpd.service

重新启动并验证。

# systemctl status ntpd.service
ntpd.service - Network Time Service
   Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled)
   Active: active (running) since Fri 2015-01-09 16:14:00 EST; 53s ago
  Process: 664 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 700 (ntpd)
   CGroup: /system.slice/ntpd.service
           └─700 /usr/sbin/ntpd -u ntp:ntp -g
在全新安装CentOS/RHEL 7后启用 NTP 以在启动时启动

Chrony 是作为新的 NTP 客户端引入的,以取代 ntp 作为自 RHEL7 以来的默认时间同步包,因此如果我们在安装过程中配置了 NTP,它只会启用 chronyd 服务,而不是 ntpd 服务。

# systemctl status ntpd.service
ntpd.service - Network Time Service
   Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled)
   Active: inactive (dead)

即使我们已启用 NTP 在启动时启动,它也不会在启用 chrony 时启动。
因此,要使 NTP 在启动时启动,我们必须禁用 chrony 服务

如果我们只想使用 NTP,那么执行下面的操作。

日期:2020-09-17 00:12:47 来源:oir作者:oir