首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >设置本地分层2 NTP服务器

设置本地分层2 NTP服务器
EN

Server Fault用户
提问于 2010-06-21 13:56:07
回答 5查看 48.2K关注 0票数 9

我试图在没有(也永远不会)互联网连接的本地网络上设置NTP。主要的优先事项是网络上的机器是相互同步的,即使它们的同步时间不是100%准确。

我们还需要使用NTP层次结构来复制已部署系统的设置。我想要做的是拥有这样的机器层次结构:

代码语言:javascript
运行
复制
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.x网络,另一个连接在10.1.4.x网络上。RackCard23在10.1.3.x网络上与主服务器Moon同步,RackCard22 22/23将在10.1.4.x网络上连接到RackCard23。这是因为我不想让RackCards22 22/23离开他们的网络同步时间,因为它复制了最终部署的系统。

到目前为止,我已经成功地获得了所有应该通过同步月亮同步来正确同步的东西(包括RackCard23)。

但是我很难让RackCard22和23同步到RackCard23。

代码语言:javascript
运行
复制
[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的输出:

代码语言:javascript
运行
复制
[rootRackCard23]# /usr/sbin/ntptrace
localhost.localdomain: stratum 16, offset 0.000000, synch distance 0.000030

如您所见,这台机器正在将自己报告为一个16层服务器,尽管它已经被同步到一个“server 1”服务器(Moon):

代码语言:javascript
运行
复制
[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

客户端(RackCard21 21/22)的配置如下所示:

代码语言:javascript
运行
复制
[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给出了以下内容:

代码语言:javascript
运行
复制
[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

所以它找不到合适的服务器,因为我试图使用的服务器是报告它是一个16层服务器(我认为这意味着不同步)。这是尽管它是同步的事实。

因此,我需要以某种方式使RackCard23成为一个更高的层(理想的是第2层)。我该怎么做呢?

任何帮助都是非常感谢的,因为我已经试着让这个工作几天了!

编辑:

你好克里斯托弗

我一直在重新启动ntpd,是的;)

所有的linux机箱都在运行CentOS 5.4。

这是您建议的命令的输出。首先从服务器:

代码语言:javascript
运行
复制
[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

然后从客户那里:

代码语言:javascript
运行
复制
[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
EN

回答 5

Server Fault用户

发布于 2010-06-21 14:19:31

正如Chris提到的,分层16表示服务器实际上没有与服务器同步。为了确定的是,您确实重新启动了ntp服务,对吗?(service ntpd restart)我并不是想暗示您错过了简单的东西,但我总是这样做!

你能发布一些更多的命令来帮助诊断吗?

客户机和服务器上的ntpq -p。应该显示它配置了哪些服务器,以及这些服务器的状态。

服务器上的ntpdc -c monlist。应该向客户展示相关信息。

另外,由于您没有提到操作系统,所以我使用RHEL样式命令运行。如果你有什么不同的话请告诉我。

编辑后,进一步的信息

好的,看到您的输出,下面是您的问题:您没有分层1服务器。事实上,“月亮”是用它的本地时钟。它将自己报告为一个16层服务器。供您参考,Stratum1服务器将有一个本地GPS或原子钟。有那种吗?否则,月亮需要将它的时钟与另一个ntp服务器同步。如果它没有网络接入,你需要伪造它的阶层。(这要求你不要太在意“真实”的时间。但其他读到这篇文章的人应该注意到这一点。)

在月亮上,将以下一行添加到ntp.conf文件中:fudge 127.127.1.0 stratum 10。这将使它将其本地时钟报告为第10层,这将使所有其他服务器在其本地层16时钟上使用该时钟。

-克里斯托弗·卡雷尔

票数 6
EN

Server Fault用户

发布于 2014-12-01 09:36:52

可能没有主题,本地Stratum 2服务器需要连接到Stratum 1服务器,而在您的孤立网络中,您没有连接。

你可以买到一个便宜的GPS模块和一个Raspberry Pi,它是一台单板电脑,具有极低的功耗和丰富的接口能力。将您的GPS模块连接到Raspberry Pi并将Pi加入到您的网络中,使用适当的软件,您的Stratum 1 NTP服务器可以是您的Stratum 1 NTP服务器,或者因为您在您的网络中的每台计算机上都有它,所以与您的时间同步。

票数 3
EN

Server Fault用户

发布于 2010-06-21 14:03:12

NTPd将根据以下内容设置自己的阶层:

  1. 如果没有评估本地时钟的漂移,将分层设置为16。此过程在正常服务器上大约需要15分钟,然后继续下一步。
  2. 连接到所有配置的时间服务器,评估哪些服务器是可靠的(因此首选),将本地层设置为最低可靠服务器的层加一个。因此,如果找到的最低可靠服务器为1,则本地服务器为2。

(这不一定是事件的顺序,而是为设置本地阶层而处理事件的顺序。)

(而且,分层16并不一定意味着它是不同步的)。

票数 2
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/153206

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档