微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

linux – 在RHEL6上使用时钟转换启用NTP

我有一台运行Oracle数据库的RHEL6服务器.构建服务器时,未启用或配置NTP.我的任务是在不影响数据库的情况下这样做.在做了一些研究之后,我假设在RHEL6上启用NTP时,时间会漂移直到它同步.但是,当我在我的测试机器上执行此操作时,系统立即跳转到NTP时间.在启用NTP之前,时间约为2 1/2分钟.当我运行ntpstat命令时,它暂时不同步但现在处于同步状态.

那么,我如何启用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

解决方法

如果时钟关闭,NTPD可以以慢速增量调整时钟.这背后的想法是缓慢的步骤不会导致软件定时器问题,日志文件和数据等奇怪的差距.

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"

原文地址:https://www.jb51.cc/linux/397264.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐