我有一台运行 CentOS 7 的服务器
要安装 ntp 模块,我遵循以下步骤:
yum install -y ntp
systemctl start ntpd
systemctl enable ntpd
systemctl status ntpd
timedatectl set-timezone America/Mexico_City
服务正在运行,我没有收到任何错误,
systemctl status ntpd
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2018-04-07 12:43:43 CDT; 50min left
Process: 2652 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 2653 (ntpd)
CGroup: /system.slice/ntpd.service
└─2653 /usr/sbin/ntpd -u ntp:ntp -g
Apr 07 12:43:43 i7box ntpd[2653]: Listen normally on 6 enp3s0 fe80::1cfd:83c7:5a71:977c UDP 123
Apr 07 12:43:43 i7box ntpd[2653]: Listen normally on 7 lo ::1 UDP 123
Apr 07 12:43:43 i7box ntpd[2653]: Listening on routing socket on fd #24 for interface updates
Apr 07 12:43:43 i7box systemd[1]: Started Network Time Service
但是当我输入timedatectl
timedatectl
Local time: Sat 2018-04-07 12:43:45 CDT
Universal time: Sat 2018-04-07 17:43:45 UTC
RTC time: Sat 2018-04-07 17:43:45
Time zone: America/Mexico_City (CDT, -0500)
NTP enabled: no
NTP synchronized: yes
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
Sun 2018-04-01 01:59:59 CST
Sun 2018-04-01 03:00:00 CDT
Next DST change: DST ends (the clock jumps one hour backwards) at
Sun 2018-10-28 01:59:59 CDT
Sun 2018-10-28 01:00:00 CST
NTP 显示为NTP enabled: no
,我已经打开了端口 123/udp
是否缺少了某个步骤?
答案1
如果这确实是问题所在,那么缺少的步骤NTP enabled: yes
是:
timedatectl set-ntp true
但是,ntpd
即使没有以下情况,你的工作也可能很好:
您可以使用 查看更详细的信息ntpd -q
。它将列出用于同步的服务器及其状态。这些服务器在中配置/etc/ntp.conf
,您可以更改默认
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
与您附近的池服务器。目前mx.pool.ntp.org
没有足够的服务器(您可能加入池):
该区域的服务器数量不足,建议您使用北美区域(
north-america.pool.ntp.org
):server 0.north-america.pool.ntp.org server 1.north-america.pool.ntp.org server 2.north-america.pool.ntp.org server 3.north-america.pool.ntp.org