执行ntptime报ERROR错误分析

一、解决方法

修改ntp.conf注释掉以下几行

tinker dispersion 100
tinker step 1800
tinker stepout 3600

或者直接用以下命令:

sed -i 's/tinker/#tinker/g' /etc/ntp.conf

最后重启ntp服务

sudo service ntpd restart

二、了解参数的作用

参考官方文档:http://doc.ntp.org/4.2.6/miscopt.html#tinker

  1. tinker [ allan allan | dispersion dispersion | freq freq | huffpuff huffpuff | panic panic | step step | stepout stepout ]

      This command alters certain system variables used by the clock discipline algorithm. 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. The options are as follows:

     

      allan allan

      Spedifies the Allan intercept, which is a parameter of the PLL/FLL clock discipline algorithm, in seconds with default 1500 s.

     

      dispersion dispersion

      Specifies the dispersion increase rate in parts-per-million (PPM) with default 15 PPM.

     

      freq freq

      Spedifies the frequency offset in parts-per-million (PPM) with default the value in the frequency file.

     

      huffpuff huffpuff

      Spedifies the huff-n'-puff filter span, which determines the most recent interval the algorithm will search for a minimum delay. The lower limit is 900 s (15 m), but a more reasonable value is 7200 (2 hours).

     

      panic panic

      Spedifies the panic threshold in seconds with default 1000 s. If set to zero, the panic sanity check is disabled and a clock offset of any value will be accepted.

     

      step step

      Spedifies the step threshold in seconds. The default without this command is 0.128 s. If set to zero, step adjustments will never occur. Note: The kernel time discipline is disabled if the step threshold is set to zero or greater than 0.5 s.

     

      stepout stepout

      Specifies the stepout threshold in seconds. The default without this command is 900 s. If set to zero, popcorn spikes will not be suppressed.

三、寻找答案

  1. 为什么在时钟没有问题的情况下,执行ntptime会报ERROR错呢?

    经过验证"maximum error"的值达到16000000 us时候执行ntptime就会报错。

  2. “maximum error”这个值是干什么用的呢?

    kerninfo官方解释:获取并打印内核锁相环操作参数。仅当内核已针对精确计时功能进行了特殊修改时,此信息才可用。(官方文档:http://doc.ntp.org/4.2.6p2/ntpdc.html)
  3. 临时解决方式
    Centos6.x 重启ntpd服务,"maximum error"会重新计算。
    Centos7.x 本地测试了下,重启ntpd服务,不会重新计算这个值,返而会变高。
  4. 验证参数问题
    在生产环境注释掉#tinker step 3600,观察两个小时后发现“maximum error” 这个值会上升,但是上升到一定程度后(不超过16s)会恢复到一个比较小的值。“estimated error”值也比较小。

    由此可以证实“tinker step 3600”会影响内核计算此值,参数中也有说明“ Note: The kernel time discipline is disabled if the step threshold is set to zero or greater than 0.5 s.”

 

 

 

你可能感兴趣的:(系统管理)