将 NTP 机器与高根时间服务器同步

将 NTP 机器与高根时间服务器同步

我有一个小型机器网络,它们使用systemd-timesyncd.service并需要同步时钟。它们不需要正确,只需同步即可。我已将其中一台机器指定为 NTP 服务器,其余机器都指向这台机器,但它们需要几个小时才能同步,而且当它们同步时,会出现非常不一致的情况:

Jun 22 18:09:16 host systemd-timesyncd[10515]: Initial synchronization to time server 10.10.1.30:123 (10.10.1.30).
Jun 22 18:25:50 host systemd-timesyncd[10515]: Server has too large root distance. Disconnecting.
Jun 22 18:34:22 host systemd-timesyncd[10515]: Server has too large root distance. Disconnecting.
Jun 22 18:51:26 host systemd-timesyncd[10515]: Server has too large root distance. Disconnecting.
Jun 22 19:25:34 host systemd-timesyncd[10515]: Server has too large root distance. Disconnecting.
Jun 22 19:59:43 host systemd-timesyncd[10515]: Server has too large root distance. Disconnecting.
Jun 22 20:33:51 host systemd-timesyncd[10515]: Initial synchronization to time server 10.10.1.30:123 (10.10.1.30).
Jun 22 21:07:59 host systemd-timesyncd[10515]: Server has too large root distance. Disconnecting.
Jun 22 21:42:07 host systemd-timesyncd[10515]: Server has too large root distance. Disconnecting.
Jun 22 22:16:16 host systemd-timesyncd[10515]: Initial synchronization to time server 10.10.1.30:123 (10.10.1.30).

我该如何解决?

答案1

罪魁祸首似乎是“根距离”。这是从每个客户端通过本地 NTP 服务器(通过任何其他 NTP 服务器)到具有 GNSS 接收器或原子钟的“层 1”服务器的整个路由引入的延迟。

              +---------------------+              +---------------------+
+---------+   |   Stratum 1 server  |  20ms delay  |   Stratum 2 server  |
|GNSS rcvr|---|  Root distance: 0ms +--------------+ Root distance: 20ms |
+---------+   |       nasa.gov      |              |   0.pool.ntp.org    |
              +---------------------+              +----------+----------+
                                                              |
                                                              | 5040ms delay
                                                              |
                                              ==LAN=FIREWALL==+================
                                                              |
           +-----------------------+              +-----------+-----------+
           |      Clients          |   1ms delay  |    Stratum 3 server   |
           | Root distance: 5061ms +--------------+ Root distance: 5060ms |
           |    10.10.1.0/24       |              |      10.10.1.30       |
           +-----------------------+              +-----------------------+

由于与层 1 服务器的对齐不如与层 3 服务器的对齐重要,因此您可以将RootDistanceMaxSec=每个客户端增加到更舒适的值。 30秒可能有用。默认值为 5 秒,因此您可能会非常接近这个数字。编辑/etc/systemd/timesyncd.conf

# See timesyncd.conf(5) for details.
[Time]
NTP=10.10.1.30
#FallbackNTP=
RootDistanceMaxSec=30
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048

这将导致客户端接受10.10.1.30作为 NTP 服务器,即使它可能远离第 1 层服务器。

相关内容