已索引

“-x”表示确保系统时间不会发生跳变
“-g”表示确保节点系统时间与NTP时间误差达到1000s时,NTPD服务不会退出

下面是 man 8 ntpd 中的详细解释:

Under ordinary conditions, ntpd slews the clock so that the time is effectively continuous 
and never runs backwards. If due to extreme network congestion an  error  spike  exceeds 
the step threshold, by default 128 ms, the spike is discarded. However, if the error persists
for more than the stepout threshold, by default 900 s, the system clock is stepped to the 
correct value. In practice the need for a step has is extremely rare and almost always the 
result of a hardware failure. With the -x option the step threshold is increased  to 600 s.

-x      Normally, the time is slewed if the offset is less than the step threshold, which is
128 ms by default, and stepped if above the threshold. This option sets the  threshold to  
600  s,  which  is  well within the accuracy window to set the clock manually. Note: Since 
the slew rate of typical Unix kernels is limited to 0.5 ms/s, each second of adjustment 
requires an amortization interval of 2000 s. Thus, an adjustment as much as 600 s will take 
almost 14 days to complete. 

默认,时间误差小于128ms时,ntpd会对时间进行微调(slewed)以保证时间不回调。误差超过128ms会进行步调(stepped)。-x 选项会将阈值由128ms改为600s,这样可以保证即使人工进行了服务器时间调整,时间也不会回调,这对数据库服务器尤其重要。

Most compters today incorporate a time-of-year (TOY) chip to maintain the time during periods
when the power is off. When the machine is booted, the chip is used to initialize the operating
system time. In case there is no TOY chip or the TOY time is more than 1000 s from the server 
time, ntpd assumes something must be terribly wrong and exits with a  panic message  to  the 
system operator. With the -g option the clock will be initially set to the server time regardless 
of the chip time. However, once the clock has been set, an error greater than 1000 s will cause 
ntpd to exit anyway.

-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 threshold is exceeded after that, ntpd 
will exit with a message to the system log.        

如果 offset 超过 1000s,ntpd会退出并打印消息到系统日志,-g选项允许允许将时间设置为任意值,但是只能允许一次,如果之后再次超过,ntpd会退出并打印消息到系统日志。该选项默认在 /etc/sysconfig/ntp 中已经有了。

-- By 许望(RHCA、OCM、VCP)
最后修改:2023 年 09 月 22 日 05 : 28 PM
如果觉得我的文章对你有用,请随意赞赏