最近遇到一个 NTP 对时的问题,跟大家分享下。
客户环境:
一般来说,客户环境中都会规划 NTP Server ,专门用来进行 NTP 的对时,但是这个客户没有专门的 NTP 服务器,而是让服务器系统直接和北斗 GPS 进行对时。
Ø 4 台 Power9 服务器, AIX 系统的 IP 分别以 201 , 202 , 203 , 204
Ø 1 台 x86 服务器, Linux 系统 IP 为 114
Ø 北斗 GPS 的 IP 为 200, 但是它于其他服务器的 IP 不是同一网段。
客户反馈:
Linux 服务器对时正常, AIX 服务器对时不正常,但是 AIX 手工通过 ntpdate 的命令是可以手工同步的。因为客户应用版本的问题,客户用的操作系统是 AIX 6.1 ,而 AIX6.1 是无法通过我们经常的操作系统问题进行报修。
去现场之前准备:
客户现场沟通及测试:
AIX 系统版本: AIX 6100-09-05
NTP 版本: v3
remote refid st t when poll reach delay offset disp
==============================================================================
注:这个#符号就是客户一直说的 AIX 系统 NTP 对时有问题的地方。 Linux 系统里面是 * 号。
我就去查阅这个 # 是什么意思,查到的资料如下:
space Discarded due to high stratum and/or failed sanity checks.
x Designated falseticker by the intersection algorithm.
. Culled from the end of the candidate list.
o Selected for synchronization, pps signal in use.
我们配置过 ntp 的童鞋都知道正常的状态应该是 * (选择同步),而 # (选择距离超过最大值的同步)。
尝试解决问题:
1). 在 /etc/ntp.conf 配置文件里添加一行:
slewalways yes
2). 修改 xntpd 服务属性:
调整完,问题依旧。
-bash-4.4# ntpq -p
remote refid st t when poll reach delay offset disp
==============================================================================
因为客户应用几天后就要上线了,我们建议客户启用我们的 Plan B (通过 ntpdate 定时对时),客户也认可,三下五去二,配置号 crontab 脚本,测试脚本,完美解决。准备让客户确认的时候,这时候客户说了一句,我们 201 和 202 作为其他几十台机器的 NTP 服务器,而且 201 和 202 还是作为 NTP 服务的主备服务器(客户事先没有提过这茬)。那我事先准备好的 plan B 也不能用呀,毕竟那么多脚本,维护也是问题。
解决问题最终篇
经过上面的测试和与客户的沟通,我们只能回到 Plan A ,彻底解决这个 # 号显示问题,才能根本上解决这个 NTP 的问题。
继续查阅相关 NTP 的资料,同事(康大师)找到一篇文档,查到 ntp v4 版本里是加入了新参数可以调整 max distance
https://www.nwtime.org/wp-content/uploads/2016/04/NTP-Handbook.pdf
page 46
Several new options have been added for the ntpd command line. For the inveterate knob twiddlers several
of the more important performance variables can be changed to fit actual or perceived special conditions. In
particular, the tinker and toscommands can be used to adjust thresholds, throw switches and change limits.
page 57
A source is considered selectable only if its root distance is less than the select threshold, by default 1.5 s, but can
be changed according to client preference using the maxdist option of the tos command. When an upstream server
loses all sources, its root distance apparent to dependent clients continues to increase. The clients are not aware of this
condition and continue to accept synchronization as long as the root distance is less than the select threshold.
page 77
tos [beacon | ceiling | cohort {0 | 1} | floor | maxclock | maxdist | minclock | mindist | minsane | orphan | orphanwait ]
This command alters certain system variables used by the the clock selection and clustering algorithms. The
default values of these variables have been carefully optimized for a wide range of network speeds and reliability
expectations. Very rarely is it necessary to change the default values; but, some folks can’t resist twisting the
knobs. It can be used to select the quality and quantity of peers used to synchronize the system clock and is
most useful in dynamic server discovery schemes. The options are as follows:
maxdist
Specify the synchronization distance threshold used by the clock selection algorithm. The default is 1.5 s.
This determines both the minimum number of packets to set the system clock and the maximum roundtrip
delay. It can be decreased to improve reliability or increased to synchronize clocks on the Moon or planets.
看完这篇文档,我就感觉这个参数可能就是解决这个问题的关键所在。
最终解决方法:
tos maxdist 16
执行 ntpq –p 的命令, IP 前面为我们所熟悉的正常 * 号,测试 NTP 功能,功能正常。至此 NTP 问题完美解决。
如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!
赞0
添加新评论1 条评论
2020-06-28 10:02
NEW_UFO: @RS6000 你好,可不可以请教一下ntp的问题,15285036681
RS6000: @zwz99999 共同学习。