在RHEL6上使用时钟启用NTP

我有一个运行Oracle数据库的RHEL6服务器。 在构build服务器时,NTP未启用或未configuration。 我的任务是在不影响数据库的情况下做到这一点。 在做了一些研究之后,我假定在RHEL6上启用NTP时,时间会漂移直到同步。 但是,当我在我的testing机器上做了这个,系统时钟立即跳转到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, stratum 2, 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 

如果NTPDclosures,时钟摆动,NTPD可以缓慢增加时钟。 这背后的想法是,缓慢的步骤不会导致软件定时器的问题,日志文件和数据等奇怪的差距

Unix内核可能的最大压缩率限制在500百万分率(PPM)。 因此,时钟每秒钟可能需要2000秒才能超出可接受的范围。

根据手册页面ntpd将不会工作,如果你的时钟超过1000秒closures。 (虽然你可以通过-g开关慢慢补偿一个1000秒的偏移量已经超过3周。)

第二,当你启动ntpd时观察到的时间跳转是ntpd启动时偏移大于128 ms时,默认的ntpd行为的结果,而不是摆动时钟。 ntpd在启动时启动,但在正在运行的系统上并不完全正确。

您可以通过将-x开关添加到ntpd的启动选项来防止这种情况。 从手册:

-x
正常情况下,如果偏移量小于步进阈值(默认值为128毫秒),则时间将被调整;如果超过阈值,则时间步进。 此选项将阈值设置为600 s,这正好在精确度窗口内手动设置时钟。 注意:由于典型Unix内核的压摆率限制为0.5ms / s,因此每秒调整需要2000s的摊销间隔。因此,调整多达600s将需要将近14天才能完成。 该选项可以与-g和-q选项一起使用

在启动ntpd服务之前,可以在/etc/sysconfig/ntpdconfiguration文件中调整RHEL系统:

 # /etc/sysconfig/ntpd # Drop root to id 'ntp:ntp' by default. OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g -x"