Edg*_*ere 6 linux redhat ntp ntpd
我有一个运行多个 Linux 机器的虚拟环境,我正在计划如何管理所有的 ntp 架构。
据我所知,在 'ntp.conf' 文件中有两台服务器是没有用的,客户端应该只有一个或三个以上的 ntp 服务器,所以,我的第一种方法是让一个服务器 'server1' 指向4 台公共服务器,特别是 RHEL 的服务器,然后让其他盒子“server2”指向 server1,下面所有其他 Linux 服务器都指向 server2,但我观察到了这种架构的奇怪行为。我见过一些服务器在 server2 和它们之间不同步,甚至有时 server1 和 server2 没有完全同步。
我的第一个问题是,为什么会这样?
然后我想出了另一种架构,该架构具有相同的 server1 指向公共 ntp 服务器,然后有三个服务器,'server2'、'server3' 和 'server4' 指向 server1,下面的所有其他机器都指向 server2-4。
这种架构是否有可能改善我所有网络内的同步?
还是同步之间的性能相同?
构建它的最佳方法是什么?
已编辑
这是ntpq -p
来自 server1的输出:
remote refid st t when poll reach delay offset jitter
=========================================================================
*Time100.Stupi. .PPS. 1 u 317 1024 377 182.786 5.327 3.022
LOCAL(0) .LOCL. 10 l 46h 64 0 0.000 0.000 0.000
Run Code Online (Sandbox Code Playgroud)
这里是ntp.conf
:
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# 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 nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst
#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# Enable public key cryptography.
#crypto
includefile /etc/ntp/crypto/pw
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# Specify the key identifiers which are trusted.
#trustedkey 4 8 42
# Specify the key identifier to use with the ntpdc utility.
#requestkey 8
# Specify the key identifier to use with the ntpq utility.
#controlkey 8
# Enable writing of statistics records.
statistics clockstats cryptostats loopstats peerstats sysstats rawstats
### Added by IPA Installer ###
server 127.127.1.0
fudge 127.127.1.0 stratum 10
Run Code Online (Sandbox Code Playgroud)
以下是三个客户端的输出:
remote refid st t when poll reach delay offset jitter
==============================================================================
*server1 172.16.29.21 3 u 1 64 1 1.090 -0.138 0.036
remote refid st t when poll reach delay offset jitter
==============================================================================
*server1 172.16.29.21 3 u 1035 1024 377 1.117 -1.943 0.530
remote refid st t when poll reach delay offset jitter
==============================================================================
*server1 172.16.29.21 3 u 32 64 1 0.902 1.788 0.140
Run Code Online (Sandbox Code Playgroud)
根据您的环境中保持时间的关键程度,您可能不希望 server1 成为单点故障。如果您必须将其离线进行长时间的维护或维修,其对等方将停止同步。从那里开始一切都在走下坡路。
为什么不让 server1、server2、server3、server4 全部同步到 4 或 5 个 Internet 对等点。那么,你的内部网络可以引用这些系统吗?
传统观点认为 3 是法定人数所需要的,但您需要容忍至少一个被确定为虚假交易者或离线的情况。
请参见; 5.3.3. 上游时间服务器数量
此外,您提到了当前配置的怪异和问题。查看ntpq -p
相关主机的输出会有所帮助。
虽然严格来说 2 个服务器没有用,但最佳当前实践 RFC 草案建议至少使用 4 个。NTP 的交集算法不仅取决于服务器数量的法定人数,还取决于它们返回的时间质量- 而您无法预测这一点。所以越多越好。 拥有多达 10 个上游 NTP 服务器没有问题。
正如 Aaron 所提到的,您提议的服务器 1-4 应该都指向上游 NTP 服务器,并且您的内部系统应该指向所有 4 个服务器。服务器 1-4 也可以相互对等(在对称模式下),但这不是严格要求的。
理解为什么不应该在架构中的任何一点通过单个服务器汇集 NTP 很重要:NTP 需要多台服务器以确保准确性,而不仅仅是冗余(请参阅 NTP 文档以了解算法的说明,其中解释了原因)。(无耻的插件:我在别处写了更多关于这个的文章,包括对架构的建议。)