我正尝试在本地networking上设置NTP(没有(也不会)互联网连接。 主要优先考虑的是networking上的机器彼此同步,即使它们同步的时间不是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)
请注意,RackCards有两个以太网端口,一个连接到10.1.3.xnetworking,另一个连接到10.1.4.xnetworking。 RackCard23在主机服务器上同步,Moon将在10.1.3.xnetworking上同步,RackCard22 / 23将连接到10.1.4.xnetworking上的RackCard23。 这是因为我不希望RackCards22 / 23离开他们的networking同步时间,因为它复制了最终部署的系统。
到目前为止,我已经设法通过月球同步来正确同步(包括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
这是ntptrace的输出:
[rootRackCard23]# /usr/sbin/ntptrace localhost.localdomain: stratum 16, offset 0.000000, synch distance 0.000030
正如你所看到的,尽pipe它已经被同步到“第一层”服务器(月亮),但是该机器将自己报告为第16层服务器:
[root@RackCard23 awd]# /usr/sbin/ntpdate -d 10.1.3.10 21 Jun 13:55:09 ntpdate[19410]: ntpdate [email protected] 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
客户端(RackCard21 / 22)的configuration如下所示:
[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
ntptrace给出了这个:
[root@RackCard21]# /usr/sbin/ntpdate -d 10.1.4.23 21 Jun 14:04:34 ntpdate[14381]: ntpdate [email protected] 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
所以它不能find合适的服务器,因为我试图使用的服务器是报告,它是一个16层服务器(我相信这意味着非同步)。 尽pipe这是同步的事实。
所以我需要以某种方式使RackCard23更高的层次(理想情况下2层)。 我该如何去做呢?
任何帮助非常感谢,因为我一直试图让这个工作好几天了!
编辑:
嗨克里斯托弗,
我一直在重新启动ntpd,是的;)
所有的Linux机器都运行CentOS 5.4。
这是您build议的命令的输出。 首先从服务器:
[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
然后从客户端:
[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
正如克里斯提到的,层次16表示服务器实际上没有与服务器同步。 只要确定,你确实重新启动了ntp服务,对吧? ( service ntpd restart )我不是想暗示你错过了简单的东西,但我总是这样做!
你可以发布一些命令的输出来帮助诊断吗?
ntpq -p在客户端和服务器上。 应该显示它已经configuration了哪些服务器,以及这些服务器的统计信息。
服务器上的ntpdc -c monlist 。 应该显示客户端连接。
另外,由于您没有提到操作系统,因此我正在运行RHEL样式的命令。 让我知道你是否有不同的东西。
编辑后进一步的信息
好的,看到你的输出,这是你的问题:你没有第一层服务器。 事实上,“月亮”正在使用它的本地时钟。 它将自己报告为第16层服务器。 作为参考,Stratum1服务器将具有本地GPS或primefaces钟。 你有这些吗? 否则,Moon需要使用ANOTHER ntp服务器同步它的时钟。 如果没有networking访问权限,则需要对其阶层进行调整。 (这要求你不要太在意“真实”的时间,而你不这样做,但是其他读者应该注意这一点)。
在Moon上,将以下行添加到您的ntp.conf文件中: fudge 127.127.1.0 stratum 10 。 这将使其报告当地时钟为第10层。这将使所有其他服务器在本地层16时钟上使用它。
– 克里斯托弗·卡雷尔
可能会出现问题,本地的Stratum 2服务器需要连接到Stratum 1服务器,并且在您的隔离networking中没有。
你可以得到一个便宜的GPS模块和一个树莓派,一个单板计算机功耗最低,接口能力充足。 把你的GPS模块连接到Raspberry Pi,并用适当的软件把Pijoin到你的networking中,它可以是你的Stratum 2服务器的Stratum 1 NTP服务器,或者是你每台计算机都在你的networking中同步的时间。
NTPd将根据以下内容设置它自己的阶层:
(这不一定是事件的顺序,而是为了设置本地层而处理它们的顺序。)
(另外,第16层不一定意味着它是不同步的)。
作为一种旁白,我会包括你的ntpq输出的一些分析。 只是为了帮助您自己和其他人进行一般故障排除。
首先,从你的服务器:
[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
第一列表示这台机器configuration为同步到的两台服务器。 值得注意的是没有*或+ ,这将表明一个同步的同行或次要人选。 这意味着你的服务器不会在这里使用这个条目,但是至less在这里检查它们。
第三列“st”表示这些服务器的层次。 在这种情况下,这表示这两台机器正在使用本地时钟。 (默认层数为16)最后三列表示两个时钟有多远。 无论是在“时钟秒差”值还是两台机器之间的延迟时间之间,都会有所不同。 这里数字越大越差
这样的非同步条目的原因可能取决于一些因素:如果时钟的偏移量太大,那么ntp甚至不会尝试,因为它会在本地时间引起太大的跳跃。 如果抖动变差,则客户端将同步,直到事情稳定。 (这通常是暂时的,然而,重新分配)或者,如果你的情况,如果configuration的服务器有相同或更高的层次值,表明它们不如时间源可靠,那么客户端将不会使用它们。
– 克里斯托弗·卡雷尔