我已经编写了一个木偶模块,它通过NTP校正时间,但这只能在服务器上使用一个小的NTP偏移量。
由于各种原因,有时服务器的时间偏移超过10分钟。
当ntp偏移量太高时,我想创建一个运行exec "service ntpd stop;ntpdate ntp3.domain.local;service ntpd start“的木偶模块,以强制更正时间。
如何查看NTP偏移量是否过高,以便告诉Puppet运行此命令?还是有更好的解决方案?
发布于 2013-09-19 21:42:05
服务ntpd停止;ntpdate ntp3.domain.local;服务ntpd启动
绝对是解决这个问题的错误方法。对-g使用ntpd选项:
-g Normally, ntpd exits with a message to the system log if the
offset exceeds the panic threshold, which is 1000 s by default.
This option allows the time to be set to any value without
restriction; however, this can happen only once. If the thresh‐
old is exceeded after that, ntpd will exit with a message to the
system log. This option can be used with the -q and -x options.将其与iburst选项结合起来,就像slm所建议的那样,因为如果没有这一点,就需要ntpd年龄来纠正这种巨大的差异。它通常只在很小的步骤中尝试更改系统时间,这样依赖于时间的应用程序就不会混淆,但是iburst选项会改变这一点。
您仍然需要确保木偶在恐慌之后自动重新启动ntpd,因为根据该命令,它将固定时间一次,然后它仍然会死掉。
https://unix.stackexchange.com/questions/91477
复制相似问题