那么,我如何启用NTP并让它漂移到正确的时间而不是“强制”它同步?谢谢你的帮助!!
[root@host etc]# service ntpd status ntpd is stopped [root@host etc]# [root@host etc]# ntpdate -q time.mydomain.com server 1.1.1.1,stratum 2,offset 154.573234,delay 0.02890 2 May 15:47:59 ntpdate[21584]: step time server 1.1.1.1 offset 154.573234 sec [root@host etc]# [root@host etc]# service ntpd start Starting ntpd: [ OK ] [root@host etc]# ntpdate -q time.mydomain.com server 1.1.1.1,offset -0.000118,delay 0.02876 2 May 15:50:47 ntpdate[21606]: adjust time server 1.1.1.1 offset -0.000118 sec [root@host etc]# date Tue May 2 15:51:01 EDT 2017 [root@host etc]# ntpstat unsynchronised polling server every 64 s [root@host etc]# ntpstat synchronised to NTP server (1.1.1.1) at stratum 3 time correct to within 80 ms polling server every 1024 s
解决方法
The maximum slew rate possible is limited to 500 parts-per-million (PPM) by the Unix kernel. As a result,the clock can take 2000s for each second the clock is outside the acceptable range.
根据手册页,如果您的时钟超过1000秒,ntpd将无法工作. (虽然您可以使用-g开关调整,慢慢补偿1000秒的偏移量已经超过3周.)
其次,当您启动ntpd时,您观察到的时间跳跃是ntpd启动时偏移量大于128 ms时默认ntpd行为的步骤而不是转换时钟的结果.当ntpd在启动时启动但在运行的系统上不是您想要的时候这是有意义的.
您可以通过将-x开关添加到ntpd的启动选项来防止这种情况.从手册:
-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. This option can be used with the -g and -q options
在RHEL系统中,可以在启动ntpd服务之前调整/ etc / sysconfig / ntpd配置文件:
# /etc/sysconfig/ntpd # Drop root to id 'ntp:ntp' by default. OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g -x"