我正在设置一个 NTP 服务器(集群中的五个服务器之一)。我的配置文件:
restrict default kod nomodify notrap
driftfile /var/lib/ntp/drift
server tick.usno.navy.mil
server ntp.colby.edu
server tick.gatech.edu
#peer local-ntp.server.2
#peer local-ntp.server.3
#peer local-ntp.server.4
#peer local-ntp.server.5
Run Code Online (Sandbox Code Playgroud)
对等节点被注释掉是因为 a) 它们尚未配置 b) 我不确定是否应该使用它们。
这个想法是我配置的每个 NTP 服务器都将同步到 USNO 源。如果我们的出站连接出现故障,它们将相互同步,唯一目的是在网络上保持一致的时间。每个客户端都将配置为使用所有五个本地 NTP 服务器作为server其 ntp.conf 中的指令。
最终,使用密钥身份验证会稍微复杂一些,但现在我从简单开始。我做得对吗?
这只是我自己的 NTP 服务器的一些示例,有很多不同的方法可以做到这一点,但这是我的:
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap noquery
restrict -6 default kod nomodify notrap noquery
# Set nopeer when not configuring a peer node.
#restrict default kod nomodify notrap nopeer noquery
#restrict -6 default kod nomodify notrap nopeer noquery
Run Code Online (Sandbox Code Playgroud)
只允许受信任的网络主机 + localhost
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 127.0.0.1 #This is optional depending on your local machine's requirements
Run Code Online (Sandbox Code Playgroud)
服务器和对等点之间的区别
ntp服务器A
server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
peer myntp.server.b
Run Code Online (Sandbox Code Playgroud)
ntp服务器B
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst
peer myntp.server.a
Run Code Online (Sandbox Code Playgroud)
对于网络上将连接到 ntp 服务器的其余服务器,您还可以使用以下prefer选项:
server 192.168.1.125 prefer # Prefer your own NTP server over others listed
Run Code Online (Sandbox Code Playgroud)
多服务器/对等 ntp 网络的一个示例。请注意了每个NTP并不会具有相同的servers上市。这是为了更好地使用对等同步。因此对等同步可以匹配不同的时间结果。
1a 1b 1c 1d 1e 1f outside
. \ / ...... \ / ...... \ / ..............
2a ---p--- 2b ---p--- 2c inside
/|\ /|\ /|\
/ | \ / | \ / | \
3a 3b 3c 3e 3f 3g 3h 3i 3j
Key: 1 = stratum-1, 2 = stratum-2, 3 = stratum-3, p = peer
#Diagram + more info: http://www.ntp.org/ntpfaq/NTP-s-config-adv.htm
Run Code Online (Sandbox Code Playgroud)
更多信息:http : //doc.ntp.org/4.1.1/confopt.htm
希望有帮助。
我的想法是,我配置的每个 NTP 服务器都将同步到 USNO 源。
所以每个人都有一条server线。这倒是有几分道理。
如果我们的出站连接出现故障,它们将相互同步,其唯一目的是保持网络时间一致。
他们将尝试彼此同步,但行不通。所有时钟源都消失了,因此服务器最终将停止提供时间。只要停电时间不是太长,这可能就没问题。
如果您想要互联网备份(并且您甚至不想放入便宜的无线电/GPS 时钟),那么您可以回退到服务器上的本地时钟。最简单的方法是选择一台服务器并添加:
server 127.127.1.0
fudge 127.127.1.0 stratum 10
Run Code Online (Sandbox Code Playgroud)
该服务器将成为后备服务器,如果所有其他时钟源消失,每个人都会跟随它。NTP 不允许您设置一组计算机并将它们同步到一起。相反,它试图分发一些“实时”源。CPU 时钟通常不被视为这样,因此上面的代码行使它发生。
现在,如果您将相同的东西放在所有服务器上,每个服务器都会认为其本地时钟比邻居的更好,并且它们不会一起漂移。