I have a RHEL6 server running an Oracle database. When the server was built, NTP wasn't enabled or configured. My task is to do that without impacting the database. After doing some research, I was under the assumption that, when enabling NTP on RHEL6, the time would drift until it was in sync. However, when I did this on my test machine, the system clocked immediately jumped to the NTP time. The time was approximately 2 1/2 minutes off before enabling NTP. When I ran the ntpstat
command, it was unsynchronized for a little while but is now in sync.
So, how do I enable NTP and have it drift into the correct time instead of "brute-forcing" it into sync? Thanks for your help!!
[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
Best Answer
NTPD can adjust your clock in slow increments if it's off, clock slewing. The idea behind that is that slow steps won't cause issues with software timers, strange gaps in log files and your data etc.
According to the manual page ntpd won't work if your clock is more then 1000 seconds off. (Although you can tune that with the -g switch slowly compensating a 1000 second offset will already take more than 3 weeks.)
Second the time jump you observed when you started
ntpd
is the result of the default ntpd behaviour to step rather than slew the clock when the offset is greater than 128 ms when ntpd starts up. That makes sense when ntpd is started at boot but not quite what you want on a running system.You can prevent that by adding the
-x
switch to the start-up options for ntpd. From the manual:In RHEL systems that would be adjusted the in
/etc/sysconfig/ntpd
config file before starting the ntpd service: