当我在 Ubuntu 中按照以下步骤操作时,NTP 已启用并同步。然而,在 Debian Jessie 中情况正好相反。有人知道 Debian 说“不”的原因吗?由于“当地时间”是正确的,我还应该担心吗?
采取的步骤
$ timedatectl set-timezone Europe/London
$ sudo apt-get install -y ntp
$ cat /etc/ntp.conf
driftfile /var/lib/ntp/ntp.drift
server 0.uk.pool.ntp.org iburst
server 1.uk.pool.ntp.org iburst
server 2.uk.pool.ntp.org iburst
server 3.uk.pool.ntp.org iburst
restrict 127.0.0.1
restrict ::1
$ service ntp stop
$ ntpd -gq
$ service ntp start
$ systemctl enable ntp
$ systemctl restart ntp
Debian 状态
$ timedatectl
Local time: Sun 2018-05-27 08:57:32 BST
Universal time: Sun 2018-05-27 07:57:32 UTC
RTC time: Sun 2018-05-27 07:57:30
Time zone: Europe/London (BST, +0100)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
Sun 2018-03-25 00:59:59 GMT
Sun 2018-03-25 02:00:00 BST
Next DST change: DST ends (the clock jumps one hour backwards) at
Sun 2018-10-28 01:59:59 BST
Sun 2018-10-28 01:00:00 GMT
$ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
+h88-150-240-202 217.114.59.66 3 u 36 64 1 10.349 -1.919 0.882
*ntp3.wirehive.n 195.66.241.2 2 u 33 64 3 13.717 -0.094 1.398
+ns1.do.steersne 195.66.241.3 2 u 32 64 3 9.994 -1.230 0.947
Ubuntu 状态
$ timedatectl
Local time: Sun 2018-03-14 10:51:48 GMT
Universal time: Sun 2018-03-14 10:51:48 UTC
RTC time: Sun 2018-03-14 10:51:46
Time zone: Europe/London (GMT, +0000)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
要启用时间同步,
timedatectl
请使用以下命令。这将启用该
systemd
服务systemd-timesyncd.service
。从man timedatectl
.因此,例如
ntp
或chrony
已经在运行但timedatectl
可能没有意识到这一点是可能的。此外,您可能必须配置您的 NTP 服务器,
/etc/systemd/timesyncd.conf
除非您通过 DHCP 获取您的 NTP 服务器,或者它们也可能在相应的配置中进行systemd-networkd.service
配置。有关详细信息,请参阅man systemd-timesyncd.service
。