手动更改后 NTP 是否应该更新时间?

手动更改后 NTP 是否应该更新时间?

我已经配置了NTP服务并通过以下方式检查了它:

  1. 禁用 NTP
  2. 调整时间
  3. 启用 NTP

主持人的时间固定的几秒钟内。但如果我这样做:

  1. 启用 NTP
  2. 调整时间

时间是未固定。这种情况下时间应该固定吗?
我通过类似 OS 的命令设置时间 /bin/date -s "4:2" && /sbin/hwclock -w
Debian 3.2.68-1+deb7u5
ntp.conf(除行外,其他均为默认server):

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

driftfile /var/lib/ntp/ntp.drift


# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable


# You do need to talk to an NTP server or two (or three).
server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst

# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
#server 0.debian.pool.ntp.org iburst
#server 1.debian.pool.ntp.org iburst
#server 2.debian.pool.ntp.org iburst
#server 3.debian.pool.ntp.org iburst


# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust


# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient

答案1

答案是“是又不是”。

当本地和 ntp 服务器之间的差异太大时(我认为大约是 0.5 秒?),NTP 将不会更新服务器上的时间。但是,当它检测到差异太大并决定这样做时,它可以在一段时间后恢复时间以进行纠正。

您可以使用以下方法更改该时间:

tinker panic 0 stepout 120

2 分钟后将返回正确时间(如果我没记错的话默认是 15 分钟……当然取决于实施)。

这是为什么?

NTP 会尝试尽可能小的修正,以保持时间线性和真正正确。如果差异太大,它就无法保持正确,因为修复时间可能需要很长时间(大多数情况下修复时间约为 1-10 毫秒)。

当您的本地时钟运行不正常且太慢时,正常运行时也会出现太大的差异,因此差异会越来越大,最后变得太大而ntpd无法再固定时间。

相关内容