我正在尝试在没有(并且永远不会)互联网连接的本地网络上设置 NTP。主要优先事项是网络上的机器彼此同步,即使它们同步的时间不是 100% 准确。
我们还需要使用 NTP 层次结构来复制已部署系统的设置。我想要做的是拥有这样的机器层次结构:
Moon (Main Server running Windows) (10.1.3.10)
|____Earth (Linux x64 client) (10.1.3.1)
|____Mars (Linux x64 client) (10.1.3.2)
|____Saturn (Linux x64 client) (10.1.3.3)
|____RackCard23 (Linux x64 client and server to the two machines below) (10.1.3.23)
|___RackCard21 (Linux x64 client) (10.1.4.21)
|___RackCard22 (Linux x64 client) (10.1.4.22)
Run Code Online (Sandbox Code Playgroud)
请注意,RackCard 有两个以太网端口,一个连接到 10.1.3.x 网络,另一个连接到 10.1.4.x 网络。与主服务器 Moon 同步的 RackCard23 将在 10.1.3.x 网络上执行此操作,而 RackCard22/23 将连接到 10.1.4.x 网络上的 RackCard23。这是因为我不希望 RackCards22/23 离开他们的网络来同步时间,并且因为它复制了最终部署的系统。
到目前为止,我已经设法通过将 Moon 同步以正确同步(包括 RackCard23)来获得所有应有的东西。
但是我很难让 RackCard22 和 23 同步 RackCard23。
[root@RackCard23]# cat /etc/ntp.conf
# NTP Deamon Configuration File "ntp.conf"
# Created on 27/04/2010
# Original backed-up as "ntp.conf.backup"
server 10.1.3.10 iburst minpoll 4 maxpoll 4 prefer #This is what we want to happen
fudge 127.127.1.0 stratum 2 #Not sure about these two lines, was trying to force it to be a stratum 2 server
fudge 127.127.0.1 stratum 2
# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntp/drift
restrict 10.1.3.10 mask 255.255.255.255 nomodify notrap noquery
#Attempt to get to act as an NTP Server
broadcast 10.1.4.255
restrict 10.1.3.21 mask 255.255.255.255 nomodify notrap
restrict 10.1.4.21 mask 255.255.255.255 nomodify notrap
Run Code Online (Sandbox Code Playgroud)
这是 ntptrace 的输出:
[rootRackCard23]# /usr/sbin/ntptrace
localhost.localdomain: stratum 16, offset 0.000000, synch distance 0.000030
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,该机器将自己报告为第 16 层服务器,尽管它已同步到“第 1 层”服务器(Moon):
[root@RackCard23 awd]# /usr/sbin/ntpdate -d 10.1.3.10
21 Jun 13:55:09 ntpdate[19410]: ntpdate 4.2.2p1@1.1570-o Tue May 19 13:57:56 UTC 2009 (1)
Looking for host 10.1.3.10 and service ntp
host found : 10.1.3.10
transmit(10.1.3.10)
receive(10.1.3.10)
transmit(10.1.3.10)
receive(10.1.3.10)
transmit(10.1.3.10)
receive(10.1.3.10)
transmit(10.1.3.10)
receive(10.1.3.10)
transmit(10.1.3.10)
server 10.1.3.10, port 123
stratum 1, precision -6, leap 00, trust 000
refid [LOCL], delay 0.04135, dispersion 0.00383
transmitted 4, in filter 4
reference time: cfc99402.e010624d Mon, Jun 21 2010 8:32:18.875
originate timestamp: cfc9dfad.48000000 Mon, Jun 21 2010 13:55:09.281
transmit timestamp: cfc9dfad.47e27179 Mon, Jun 21 2010 13:55:09.280
filter delay: 0.04155 0.04155 0.04137 0.04135
0.00000 0.00000 0.00000 0.00000
filter offset: -0.01448 0.000781 0.000537 0.000394
0.000000 0.000000 0.000000 0.000000
delay 0.04135, dispersion 0.00383
offset 0.000394
21 Jun 13:55:09 ntpdate[19410]: adjust time server 10.1.3.10 offset 0.000394 sec
Run Code Online (Sandbox Code Playgroud)
客户端 (RackCard21/22) 的配置如下所示:
[root@RackCard21]# cat /etc/ntp.conf
# NTP Deamon Configuration File "ntp.conf"
# Created on 27/04/2010
# Original backed-up as "ntp.conf.backup"
server 10.1.4.23 iburst minpoll 4 maxpoll 4 prefer
server 127.127.1.0
fudge 127.127.1.0 stratum 10
# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntp/drift
# restrict 127.0.0.1
restrict None mask 255.255.255.255 nomodify notrap noquery
Run Code Online (Sandbox Code Playgroud)
ntptrace 给出了这个:
[root@RackCard21]# /usr/sbin/ntpdate -d 10.1.4.23
21 Jun 14:04:34 ntpdate[14381]: ntpdate 4.2.2p1@1.1570-o Tue May 19 13:57:56 UTC 2009 (1)
Looking for host 10.1.4.23 and service ntp
host found : 10.1.4.23
transmit(10.1.4.23)
receive(10.1.4.23)
transmit(10.1.4.23)
receive(10.1.4.23)
transmit(10.1.4.23)
receive(10.1.4.23)
transmit(10.1.4.23)
receive(10.1.4.23)
transmit(10.1.4.23)
10.1.4.23: Server dropped: strata too high
server 10.1.4.23, port 123
stratum 16, precision -20, leap 11, trust 000
refid [10.1.4.23], delay 0.02568, dispersion 0.00000
transmitted 4, in filter 4
reference time: 00000000.00000000 Thu, Feb 7 2036 6:28:16.000
originate timestamp: cfc9dfef.12b79516 Mon, Jun 21 2010 13:56:15.073
transmit timestamp: cfc9e1e2.aeae7d56 Mon, Jun 21 2010 14:04:34.682
filter delay: 0.02573 0.02571 0.02568 0.02568
0.00000 0.00000 0.00000 0.00000
filter offset: -499.609 -499.609 -499.609 -499.609
0.000000 0.000000 0.000000 0.000000
delay 0.02568, dispersion 0.00000
offset -499.609286
21 Jun 14:04:34 ntpdate[14381]: no server suitable for synchronization found
Run Code Online (Sandbox Code Playgroud)
因此它找不到合适的服务器,因为我尝试使用的服务器报告它是第 16 层服务器(我认为这意味着非同步)。尽管事实上它是同步的。
所以我需要以某种方式使 RackCard23 成为一个更高的层次(理想情况下是第 2 层)。我该怎么做?
任何帮助都非常感谢,因为我一直试图让它工作好几天!
编辑:
嗨克里斯托弗,
我一直在重新启动 ntpd,是的;)
所有的 linux 机器都运行 CentOS 5.4。
这是您建议的命令的输出。首先从服务器:
[root@RackCard23]# /usr/sbin/ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
10.1.3.10 .INIT. 16 u - 16 0 0.000 0.000 0.000
10.1.4.255 .BCST. 16 u - 64 0 0.000 0.000 0.001
[root@RackCard23]# /usr/sbin/ntpdc -c monlist
remote address port local address count m ver code avgint lstint
===============================================================================
localhost.localdomain 34566 127.0.0.1 1 7 2 0 0 0
10.1.4.21 123 10.1.4.23 5 3 4 180 5 1
10.1.4.22 123 10.1.4.23 7 3 4 0 2 2
Run Code Online (Sandbox Code Playgroud)
然后从客户端:
[root@RackCard21]# /usr/sbin/ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
10.1.4.23 .INIT. 16 u 10 16 0 0.000 0.000 0.000
LOCAL(0) .LOCL. 10 l 44 64 1 0.000 0.000 0.001
Run Code Online (Sandbox Code Playgroud)
正如克里斯提到的,层 16 表示服务器实际上没有与服务器同步。可以肯定的是,您确实重新启动了 ntp 服务,对吗?( service ntpd restart) 我不是要暗示你错过了简单的东西,但我总是这样做!
你能发布更多命令的输出来帮助诊断吗?
ntpq -p在客户端和服务器上。应该显示它配置了哪些服务器,以及这些服务器的统计信息。
ntpdc -c monlist在服务器上。应显示已连接的客户端。
另外,由于您没有提到操作系统,我正在使用 RHEL 样式的命令运行。如果你有不同的东西,请告诉我。
编辑更多信息
好的,看到您的输出,这是您的问题:您没有第 1 层服务器。事实上,“月亮”正在使用它的本地时钟。它将自己报告为第 16 层服务器。供您参考,Stratum1 服务器将具有本地 GPS 或原子钟。你有其中之一吗?否则,Moon 需要将其时钟与另一个 ntp 服务器同步。如果它没有网络访问权限,您将需要捏造它的层。(这要求你不要太在意“真实”时间。你不会,但其他阅读本文的人应该注意这一点。)
在月亮下面一行添加到您的ntp.conf文件:fudge 127.127.1.0 stratum 10。这将使它报告其本地时钟为第 10 层。这将使所有其他服务器在其本地第 16 层时钟上使用它。
——克里斯托弗·卡雷尔
NTPd 将根据以下条件设置自己的层:
(这不一定是事件的顺序,而是为了设置本地层而处理事件的顺序。)
(此外,层 16 并不一定意味着它不同步)。
| 归档时间: |
|
| 查看次数: |
43987 次 |
| 最近记录: |