ntp什么时候更新时间

ntp什么时候更新时间

我在同一 LAN 上有两台 debian wheezy 机器,它们使用 NTP 同步时钟。使用date我看到时间是同步的。然后我date --set在其中一台机器上将时间调回大约 30 秒。

该服务何时会ntp校正时钟?大约过了15分钟,两台机器的输出仍然有30秒的差异date。我知道我可以强制更新时钟,但我想知道该ntp服务自动更新时钟的速度有多快。

这是一些状态:

root@unassigned-hostname:# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 materialinmotio .CDMA.           1 u  621 1024  377   78.039  18621.9 18622.5
 hadb2.smatwebde 200.98.196.212   2 u  451 1024  377   36.824  18621.8 18622.1
 ntp.newfxlabs.c 216.218.192.202  2 u   25 1024  377   69.693  18623.6 17241.1
 time.tritn.com  216.218.192.202  2 u  284 1024  377   69.584    0.466 7038.56
root@unassigned-hostname:# service ntp status
NTP server is running.

和我的/etc/ntp.conf:

# /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 ntp.your-provider.example

# 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

*您显示的客户端未同步到任何服务器(第一列中没有标记)。与之前的尝试相比,所有这些都完全可以达到(达到 = 377,最大值)。然而,守护进程只会每 1024 秒(轮询间隔)检查一次,因为它要么已配置为稳定,要么客户端的时间已经稳定,并且距离该时间最多还有 400 秒(当 = 621 时)。

当客户端发现时间严重错误时,它会开始将时间恢复到正确值。如果幸运的话,它还会将轮询间隔降回起始值,以便可以安全地更快地同步。


我刚刚尝试把时间退回到这里的备用盒子上。我看到我的系统仍然与其上游同步(*在第一列中),但偏移量已达到 30004.6(即 30 秒),并且抖动已增加到 30000.3。轮询时间并没有减少,因此至少还需要一个 1024 秒的周期才能意识到它已经穿越了时间扭曲。

ntpq -pn                                                                                        

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+5.196.160.139   145.238.203.14   2 u  211 1024  377    0.879  30004.6 30000.3
*195.154.79.192  222.217.153.8    2 u  607 1024  377    5.140   -0.937   1.479
+91.134.209.213  149.202.97.123   3 u  452 1024  377    0.848   -0.540   1.604
-10.20.3.131     163.172.28.46    4 u  901 1024  376    7.189    0.395   0.954

现在,几个小时后,我的系统又恢复正常了:

ntpq -pn                                                                                       

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*5.196.160.139   145.238.203.14   2 u  432 1024    7    0.755    1.954   0.049
+195.154.79.192  222.217.153.8    2 u  557 1024    1    4.955   -1.616   0.015
+91.134.209.213  149.202.97.123   3 u  429 1024    7    0.754   -0.328   0.125
 10.20.3.131     163.172.28.46    4 u  174 1024    3    7.023   -0.991   1.023

相关内容