无法让 NTP 服务器同步

无法让 NTP 服务器同步

TLDR:我得到了“Leap 11”,这意味着服务器不同步。我该如何解决这个问题?

我正在尝试解决的问题的一些背景。我有一个将放在航天器上的有效载荷。航天器提供 NTP,但只有一个服务器。我将在我们的有效载荷中安装一个子有效载荷。这个子有效载荷由不同的组织开发。子有效载荷需要访问 NTP。我们有一个专用的网络接口来与子有效载荷通信。我们无法在航天器网络和子有效载荷网络之间桥接或路由流量。因此,我们的有效载荷需要成为航天器 NTP 的客户端,并成为我们子有效载荷的服务器。我们的有效载荷运行的是 Windows 7 SP1。

我花了大量时间尝试让 Microsoft 的 w32tm 时间服务与 NTP 同步并充当 NTP 服务器。我放弃了。

我现在正在尝试使用迈伯格NTP。这似乎好多了,但我仍然有问题。服务器不断报告“leap not in sync”和“leap_alarm”和“leap 11”。我已经研究了好几天,但还是没找出问题所在。我该如何让它正常工作?

下面的示例是运行 Windows 7 的虚拟机,因此我可以轻松地进行实验并获得可靠的设置,然后再将其安装到我们的有效载荷上。

Windows 7系统上的NTP同步到远程服务器。

C:\Program Files (x86)\NTP\etc>ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 127.127.1.0     .LOCL.           6 l   65   64    2    0.000   +0.000   0.977
*128.138.XXX.XXX 128.138.YYY.YYY  2 u    6    8  377    0.977  +912.07 579.941

有关在 Windows 7 上安装的 NTP 的信息:

C:\Program Files (x86)\NTP\etc>ntpq -crv
associd=0 status=c613 leap_alarm, sync_ntp, 1 event, spike_detect,
version="ntpd 4.2.8p15-o Jun 25 14:45:34 (UTC+02:00) 2020  (2)",
processor="x86", system="Windows", leap=11, stratum=3, precision=-10,
rootdelay=2.380, rootdisp=2952.787, refid=128.138.XXX.XXX,
reftime=e313d90f.d74bc8e2  Tue, Sep 22 2020  1:59:43.841,
clock=e313d911.12cbcb26  Tue, Sep 22 2020  1:59:45.073, peer=59255, tc=3,
mintc=3, offset=+0.000000, frequency=+0.000, sys_jitter=494.744833,
clk_jitter=0.977, clk_wander=0.000

当我使用 ntpdate 查询在 Windows 7 系统上运行的 NTP 服务器时,失败:

C:\Program Files (x86)\NTP\etc>ntpdate -d -v 127.0.0.1
22 Sep 02:00:32 ntpdate[1512]: ntpdate 4.2.8p15-o Jun 25 14:48:06 (UTC+02:00) 2020  (2)
22 Sep 02:00:32 ntpdate[1512]: Raised to realtime priority class
transmit(127.0.0.1)
receive(127.0.0.1)
transmit(127.0.0.1)
receive(127.0.0.1)
transmit(127.0.0.1)
receive(127.0.0.1)
transmit(127.0.0.1)
receive(127.0.0.1)
127.0.0.1: Server dropped: leap not in sync

server 127.0.0.1, port 123
stratum 3, precision -10, leap 11, trust 000
refid [128.138.XXX.XXX], root delay 0.002380, root dispersion 3.470093
reference time:      e313d93f.d74bc6bf  Tue, Sep 22 2020  2:00:31.841
originate timestamp: e313d946.7acbce26  Tue, Sep 22 2020  2:00:38.479
transmit timestamp:  e313d94622 Sep 02:00:38 ntpdate[1512]: no server suitable for synchronization found
.7acbc713  Tue, Sep 22 2020  2:00:38.479
filter delay:  0.02658    0.02658    0.02658    0.02658
               ----       ----       ----       ----
filter offset: +0.000000  +0.000000  +0.000000  +0.000000
               ----       ----       ----       ----
delay 0.02658, dispersion 0.00000, offset +0.000000

配置文件已删除注释。子有效负载必须有一个正常工作的 NTP 服务器 - 稍微错误的服务器也比没有服务器要好。因此,我已将本地时钟配置为源。

C:\Program Files (x86)\NTP\etc>type ntp.conf
restrict default noquery nopeer nomodify notrap
restrict -6 default noquery nopeer nomodify notrap
restrict 127.0.0.1
restrict -6 ::1
restrict 172.22.11.0
driftfile "C:\Program Files (x86)\NTP\etc\ntp.drift"
server 127.127.1.0
fudge 127.127.1.0 stratum 6
server 128.138.XXX.XXX iburst minpoll 3 maxpoll 7 prefer

编辑:添加 ntpq readvar 命令的信息。

C:\Program Files (x86)\NTP\etc>ntpq
ntpq> readvar
associd=0 status=c613 leap_alarm, sync_ntp, 1 event, spike_detect,
version="ntpd 4.2.8p15-o Jun 25 14:45:34 (UTC+02:00) 2020  (2)",
processor="x86", system="Windows", leap=11, stratum=3, precision=-10,
rootdelay=2.289, rootdisp=4553.250, refid=128.138.XXX.XXX,
reftime=e3152168.e15ea3de  Wed, Sep 23 2020  1:20:40.880,
clock=e315216d.520c0641  Wed, Sep 23 2020  1:20:45.320, peer=59255, tc=3,
mintc=3, offset=+0.000000, frequency=+6.278, sys_jitter=798.325045,
clk_jitter=0.977, clk_wander=0.000

ntpq> assoc
ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 59254  90f4   yes   yes  none    reject   reachable 15
  2 59255  961a   yes   yes  none  sys.peer    sys_peer  1

ntpq> readvar 59254
associd=59254 status=90f4 conf, reach, sel_reject, 15 events, reachable,
srcadr=LOCAL(0), srcport=123, dstadr=127.0.0.1, dstport=123, leap=00,
stratum=6, precision=-10, rootdelay=0.000, rootdisp=10.000, refid=LOCL,
reftime=(no time), rec=e31520b1.e3d46a48  Wed, Sep 23 2020  1:17:37.889,
reach=010, unreach=0, hmode=3, pmode=4, hpoll=6, ppoll=6, headway=0,
flash=00 ok, keyid=0, ttl=0, offset=+0.000, delay=0.000,
dispersion=7937.988, jitter=0.977,
filtdelay=     0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00,
filtoffset=   +0.00   +0.00   +0.00   +0.00   +0.00   +0.00   +0.00   +0.00,
filtdisp=      0.98 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0

ntpq> readvar 59255
associd=59255 status=961a conf, reach, sel_sys.peer, 1 event, sys_peer,
srcadr=128.138.XXX.XXX, srcport=123, dstadr=172.22.11.179,
dstport=123, leap=00, stratum=2, precision=-18, rootdelay=1.312,
rootdisp=24.643, refid=128.138.YYY.YYY,
reftime=e3151e59.4db14951  Wed, Sep 23 2020  1:07:37.303,
rec=e3152180.e100aeac  Wed, Sep 23 2020  1:21:04.878, reach=377,
unreach=0, hmode=3, pmode=4, hpoll=3, ppoll=3, headway=1, flash=00 ok,
keyid=0, offset=+4208.463, delay=0.977, dispersion=1.094, jitter=714.431,
xleave=0.001,
filtdelay=     0.98    0.98    0.98    0.98   29.29    0.98  118.15  197.25,
filtoffset= +4208.4 +4036.9 +3901.7 +3729.3 +3516.3 +3337.0 +3256.6 +3171.4,
filtdisp=      0.98    1.10    1.22    1.34    1.46    1.58    1.70    1.82

EDIT2:删除本地时钟作为源。更改配置并重新启动。

删除了注释的配置文件。

C:\Program Files (x86)\NTP\etc>type ntp.conf
restrict default noquery nopeer nomodify notrap
restrict -6 default noquery nopeer nomodify notrap
restrict 127.0.0.1
restrict -6 ::1
restrict 172.22.11.0
driftfile "C:\Program Files (x86)\NTP\etc\ntp.drift"
server time.colorado.edu iburst minpoll 3 maxpoll 7 prefer
C:\Program Files (x86)\NTP\etc>ntpq
ntpq> readvar
associd=0 status=c613 leap_alarm, sync_ntp, 1 event, spike_detect,
version="ntpd 4.2.8p15-o Jun 25 14:45:34 (UTC+02:00) 2020  (2)",
processor="x86", system="Windows", leap=11, stratum=3, precision=-10,
rootdelay=2.319, rootdisp=899.108, refid=128.138.XXX.XXX,
reftime=e3153daa.b2084280  Wed, Sep 23 2020  3:21:14.695,
clock=e3153db1.9672107e  Wed, Sep 23 2020  3:21:21.587, peer=35575, tc=3,
mintc=3, offset=+0.000000, frequency=+16.909, sys_jitter=337.424222,
clk_jitter=0.977, clk_wander=0.000

ntpq> peer
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*128.138.XXX.XXX 128.138.YYY.YYY  2 u    5    8   377   0.977  +5100.9 810.260

ntpq> assoc
ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 35575  961a   yes   yes  none  sys.peer    sys_peer  1

ntpq> readvar 35575
associd=35575 status=961a conf, reach, sel_sys.peer, 1 event, sys_peer,
srcadr=128.138.XXX.XXX, srcport=123, dstadr=172.22.11.179,
dstport=123, leap=00, stratum=2, precision=-18, rootdelay=1.343,
rootdisp=38.300, refid=128.138.YYY.YYY,
reftime=e3153bd3.adb315a2  Wed, Sep 23 2020  3:13:23.678,
rec=e3153e8e.af79f93e  Wed, Sep 23 2020  3:25:02.685, reach=377,
unreach=0, hmode=3, pmode=4, hpoll=3, ppoll=3, headway=0, flash=00 ok,
keyid=0, offset=+4486.303, delay=0.977, dispersion=1.092, jitter=606.007,
xleave=0.000,
filtdelay=     0.98    0.98    0.98    0.98    0.98   97.64    0.98    0.98,
filtoffset= +4486.3 +4378.9 +4227.2 +4084.3 +3943.5 +3853.0 +3658.4 +3511.8,
filtdisp=      0.98    1.10    1.22    1.34    1.46    1.58    1.70    1.82

EDIT3:我构建了一个全新的 Windows 7 Enterprise SP1 系统。使用校园内的两个时间服务器安装了 Meinberg NTP 的简单配置。Win7 拒绝与这些服务器同步。我编写了一个简单的脚本来尝试强制它同步,但没有成功。

@echo off

echo NTP PEERS >> ntp-query.log 2>&1
ntpq -p >> ntp-query.log 2>&1

echo. >> ntp-query.log 2>&1
echo. >> ntp-query.log 2>&1
echo NTP ASSOCIATIONS >> ntp-query.log 2>&1
ntpq -c as >> ntp-query.log 2>&1

echo. >> ntp-query.log 2>&1
echo. >> ntp-query.log 2>&1
echo NTP READVARS >> ntp-query.log 2>&1
ntpq -c rv >> ntp-query.log 2>&1

echo. >> ntp-query.log 2>&1
echo. >> ntp-query.log 2>&1
echo STOP NTP SERVICE >> ntp-query.log 2>&1
net stop ntp >> ntp-query.log 2>&1

echo. >> ntp-query.log 2>&1
echo. >> ntp-query.log 2>&1
echo SYNC CLOCK >> ntp-query.log 2>&1
ntpdate -b -v time.colorado.edu >> ntp-query.log 2>&1

echo. >> ntp-query.log 2>&1
echo. >> ntp-query.log 2>&1
echo START NTP SERVICE >> ntp-query.log 2>&1
net start ntp >> ntp-query.log 2>&1

echo. >> ntp-query.log 2>&1
echo. >> ntp-query.log 2>&1
echo NTP PEERS >> ntp-query.log 2>&1
ntpq -p >> ntp-query.log 2>&1

echo. >> ntp-query.log 2>&1
echo. >> ntp-query.log 2>&1
echo NTP ASSOCIATIONS >> ntp-query.log 2>&1
ntpq -c as >> ntp-query.log 2>&1

echo. >> ntp-query.log 2>&1
echo. >> ntp-query.log 2>&1
echo NTP READVARS >> ntp-query.log 2>&1
ntpq -c rv >> ntp-query.log 2>&1
NTP PEERS
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 tcom-gw-loop.co 128.138.140.44   2 u   65   64    3    3.897  +2854.1 1695.66
 utcnist2.colora .NIST.           1 u   59   64    3   19.527  +2981.0 1708.88


NTP ASSOCIATIONS
ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 48693  901a   yes   yes  none    reject    sys_peer  1
  2 48694  901a   yes   yes  none    reject    sys_peer  1


NTP READVARS
associd=0 status=c018 leap_alarm, sync_unspec, 1 event, no_sys_peer,
version="ntpd 4.2.8p15-o Jun 25 14:45:34 (UTC+02:00) 2020  (2)",
processor="x86", system="Windows", leap=11, stratum=2, precision=-10,
rootdelay=19.771, rootdisp=1645.581, refid=128.138.141.172,
reftime=e323864f.c85581a0  Sat, Oct  3 2020 23:22:55.782,
clock=e32386e0.89558364  Sat, Oct  3 2020 23:25:20.536, peer=0, tc=6,
mintc=3, offset=+0.000000, frequency=+0.000, sys_jitter=0.000000,
clk_jitter=0.977, clk_wander=0.000


STOP NTP SERVICE
The Network Time Protocol Daemon service is stopping.
The Network Time Protocol Daemon service was stopped successfully.



SYNC CLOCK
 3 Oct 23:25:23 ntpdate[1688]: ntpdate 4.2.8p15-o Jun 25 14:48:06 (UTC+02:00) 2020  (2)
 3 Oct 23:25:23 ntpdate[1688]: Raised to realtime priority class
 3 Oct 23:25:33 ntpdate[1688]: step time server 128.138.82.156 offset +4.142855 sec


START NTP SERVICE
The Network Time Protocol Daemon service is starting.
The Network Time Protocol Daemon service was started successfully.



NTP PEERS
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 tcom-gw-loop.co 128.138.140.44   2 u    1   64    1   35.147  +68.050   0.977
 utcnist2.colora .NIST.           1 u    1   64    1   16.598  +56.055   0.977


NTP ASSOCIATIONS
ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 49563  9014   yes   yes  none    reject   reachable  1
  2 49564  9014   yes   yes  none    reject   reachable  1


NTP READVARS
associd=0 status=c016 leap_alarm, sync_unspec, 1 event, restart,
version="ntpd 4.2.8p15-o Jun 25 14:45:34 (UTC+02:00) 2020  (2)",
processor="x86", system="Windows", leap=11, stratum=16, precision=-10,
rootdelay=0.000, rootdisp=0.045, refid=INIT, reftime=(no time),
clock=e32386f0.0b989634  Sat, Oct  3 2020 23:25:36.045, peer=0, tc=3,
mintc=3, offset=+0.000000, frequency=+0.000, sys_jitter=0.000000,
clk_jitter=0.977, clk_wander=0.000

答案1

我认为这里发生的情况是您的系统和上游 NTP 对本月是否有闰秒存在分歧。但是,这只是猜测,可能不适用于您的情况。

以下是我系统中的一个例子,用于说明如何解决。我的本地服务器显示没有闰秒(leap_none 和 leap=00):

ntpq> rv
associd=0 status=0615 leap_none, sync_ntp, 1 event, clock_sync,
version="ntpd [email protected] (1)", processor="x86_64",
system="Linux/4.19.0-9-amd64", leap=00, stratum=2, precision=-18,
rootdelay=0.564, rootdisp=6.541, refid=172.22.254.53,
reftime=e3150f56.6c8ad2f3  Wed, Sep 23 2020 10:03:34.423,
clock=e3151066.bbdbd233  Wed, Sep 23 2020 10:08:06.733, peer=8919, tc=6,
mintc=3, offset=0.261720, frequency=10.858, sys_jitter=0.191792,
clk_jitter=0.486, clk_wander=0.013

从我的同步对等点查找值:

# ntpq -n
ntpq> peers
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000    0.000   0.004
 time.apple.com  .POOL.          16 p    -   64    0    0.000    0.000   0.004
 time.windows.co .POOL.          16 p    -   64    0    0.000    0.000   0.004
-2001:44b8:2100: 239.29.146.228   2 s  190 1024  377    0.438   -0.020   0.099
*172.22.254.53   .PPS.            1 s  346 1024  377    0.770   -0.063  10.898
+172.22.160.64   172.22.254.53    2 s  361 1024  377    0.389   -0.154   0.237
+172.22.160.61   17.253.66.253    2 s  117 1024  377    0.661   -0.052   0.108
 47.51.249.154   .PPS.            1 u  620 1024    1  232.253    1.231   0.385
 2a03:2880:ff0c: .FB...           1 u  225 1024  377   17.630    0.167   4.988
 2606:4700:f1::1 10.26.8.188      3 u  399 1024  377   19.256   -0.003   2.240
-2001:44b8:1::1  203.35.83.242    2 u  375 1024  377    6.329   -1.184   6.398

对等点是第 5 个关联。获取关联 ID。我们可以跳过上面的对等点显示,只需在关联表中查找条件为 sys.peer 的对等点。

ntpq> assoc
ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 37567  8811   yes  none  none    reject    mobilize  1
  2 37568  8811   yes  none  none    reject    mobilize  1
  3 37569  8811   yes  none  none    reject    mobilize  1
  4 37570  934a   yes   yes  none   outlier    sys_peer  4
  5 37571  96fa   yes   yes  none  sys.peer    sys_peer 15
  6 37572  94fa   yes   yes  none candidate    sys_peer 15
  7 37573  94fa   yes   yes  none candidate    sys_peer 15
  8 37574  9014   yes   yes  none    reject   reachable  1
  9 37575  9024   yes   yes  none    reject   reachable  2
 10 37576  9024   yes   yes  none    reject   reachable  2
 11 37577  931a   yes   yes  none   outlier    sys_peer  1

现在获取关联 37571 的值(您的数字将会有所不同):

ntpq> rv 37571
associd=37571 status=96fa conf, reach, sel_sys.peer, 15 events, sys_peer,
srcadr=172.22.254.53, srcport=123, dstadr=172.22.254.2, dstport=123,
leap=00, stratum=1, precision=-19, rootdelay=0.000, rootdisp=1.099,
refid=PPS, reftime=e3150c9d.0367d977  Wed, Sep 23 2020  9:51:57.013,
rec=e3150ca5.0ac60428  Wed, Sep 23 2020  9:52:05.042, reach=377,
unreach=0, hmode=1, pmode=2, hpoll=10, ppoll=10, headway=0, flash=00 ok,
keyid=0, offset=-0.063, delay=0.770, dispersion=15.496, jitter=10.898,
xleave=0.096,
filtdelay=     0.77    0.82    1.51    1.13    0.63   91.45    1.09    0.82,
filtoffset=   -0.06   -0.10   -0.44   -0.01   -0.20   28.77   -0.28   -0.02,
filtdisp=      0.01   15.79   31.79   47.50   62.87   78.35   94.22  110.32

所以它也说 leap=00,一切都很好。

您的配置有一个本地时钟和一个远程对等点。找到两者的跳跃指示器值 - 我敢打赌它们是不同的。当您只有 2 个对等点时,您无法就跳跃指示器的值达成多数意见,因此它无法做出正确的决定。尝试取出本地时钟或添加另一个其跳跃指示器与您当前同步对等点一致的远程对等点。

PS,请告诉我你不会把 Windows 7 放在宇宙飞船上。:-)

相关内容