What's the difference between ntpdate and ntpd? (see further below
for ntpdate).
I've a client where we are testing moving their physical 5.0.7
server from physical hardware on-site at their office to a 507 VM
hosted by
http://www.virtacore.com/
I've restored a backup of the physical machine to the Virtacore cloud
to create the 507 VM and brought it up.
During testing, I noted that the time is off and drifting further
away from wall-clock time.
Ntpd is running with the standard /etc/ntp.conf I set up for SCO 5.0.7
systems but ntp is not adjusting the clock.
I set up a check_date script that runs every 10 minutes from root's
crontab on the 507 VM and it shows that the 507 VM is loosing time:
507VM vs 507 Physical
Tue Feb 26 15:00:00 CST 2013
Tue Feb 26 15:09:19 CST 2013 -09:19
507VM vs 507 Physical
Tue Feb 26 15:10:00 CST 2013
Tue Feb 26 15:23:05 CST 2013 -13:05
507VM vs 507 Physical
Tue Feb 26 15:20:00 CST 2013
Tue Feb 26 15:36:50 CST 2013 -16:50
507VM vs 507 Physical
Tue Feb 26 15:30:00 CST 2013
Tue Feb 26 15:50:34 CST 2013 -20:34
507VM vs 507 Physical
Tue Feb 26 15:40:00 CST 2013
Tue Feb 26 16:04:20 CST 2013 -24:20
507VM vs 507 Physical
Tue Feb 26 15:50:00 CST 2013
Tue Feb 26 16:18:05 CST 2013 -28:05
So that after 24 hours I see:
507VM vs 507 Physical
Wed Feb 27 15:40:00 CST 2013
Wed Feb 27 17:41:08 CST 2013 -2:01:08
507VM vs 507 Physical
Wed Feb 27 15:50:00 CST 2013
Wed Feb 27 17:54:53 CST 2013 -2:04:53
507VM vs 507 Physical
Wed Feb 27 16:00:00 CST 2013
Wed Feb 27 18:08:39 CST 2013 -2:08:39
507VM vs 507 Physical
Wed Feb 27 16:10:00 CST 2013
Wed Feb 27 18:22:23 CST 2013 -2:12:23
507VM vs 507 Physical
Wed Feb 27 16:20:00 CST 2013
Wed Feb 27 18:36:08 CST 2013 -2:16:08
507VM vs 507 Physical
Wed Feb 27 16:30:00 CST 2013
Wed Feb 27 18:49:54 CST 2013 -2:19.54
A google search turned up "Timekeeping-In-VirtualMachines.pdf"
but the suggestions for /etc/ntp.conf did not resolve the issue:
> INFORMATION GUIDE / 2 3
> Timekeeping in VMware Virtual Machines
> VMware vSphere 5.0, Workstation 8.0, Fusion 4.0
> Using NTP in Linux and Other Guests
> The Network Time Protocol is usable in a virtual machine with proper configuration
> of the NTP daemon. The following points are important:
>
> --> Do not configure the virtual machine to synchronize to its own
> (virtual) hardware clock, not even as a fallback with a high stratum
> number. Some sample ntpd.conf files contain a section specifying the
> local clock as a potential time server, often marked with the comment
> �undisciplined local clock.� Delete any such server specification
> from your ntpd.conf file.
>
> --> Include the option tinker panic 0 at the top of your ntp.conf file.
> By default, the NTP daemon sometimes panics and exits if the underlying
> clock appears to be behaving erratically. This option causes the daemon
> to keep running instead of panicking.
> --> Follow standard best practices for NTP: Choose a set of servers to synchronize
> to that have accurate time and adequate redundancy. If you have many virtual
> or physical client machines to synchronize, set up some internal servers for
> them to use, so that all your clients are not directly accessing an external
> low-stratum NTP server and overloading it with requests.
>
> The following sample ntp.conf file is suitable if you have few enough clients that
> it makes sense for them to access an external NTP server directly. If you have many
> clients, adapt this file by changing the server names to reference your internal NTP
> servers.
>
> NOTE: Any tinker commands used must appear first.
>
> # ntpd.conf
> tinker panic 0
> restrict 127.0.0.1
> restrict default kod nomodify notrap
> server
0.vmware.pool.ntp.org
> server
1.vmware.pool.ntp.org
> server
2.vmware.pool.ntp.org
> server
3.vmware.pool.ntp.org
>
> Here is a sample /etc/ntp/step-tickers corresponding to the sample ntp.conf file above.
>
> # step-tickers
>
0.vmware.pool.ntp.org
>
1.vmware.pool.ntp.org
>
> Make sure that ntpd is configured to start at boot time. On some distributions
> this can be accomplished with the command chkconfig ntpd on, but consult your
> distribution�s documentation for details. On most distributions, you can start
> ntpd manually with the command /etc/init.d/ntpd start.
I applied the suggestions with modifications of my standard
/etc/ntp.conf:
#
# sample /etc/ntp.conf file CLIENT configuration
# Added restrict per sample from Timekeeping-In-VirtualMachines.pdf
# removed kod as /usr/adm/syslog message indicates it as unknown cmd
#
restrict 127.127.1.0
#restrict default kod nomodify notrap
restrict default nomodify notrap
server
tick.usno.navy.mil
# ^ The IP address of the stratum 0 server machine that you would
# be asking for the time.
# Declare local clock as stratum 10 server in case we loose contact with
# Strata 1 servers and so that our machine will serve time to the network.
#server 127.127.1.0
#fudge 127.127.1.0 stratum 10
server 127.127.1.0 commented out per Timekeeping-In-VirtualMachines.pdf
The above did not work. In desperation, I set up a crontab entry
to run ntpdate one minute before common execute times for the client's
crontab scripts:
0,10,20,30,40,50 * * * * /usr/bin/checkdate > /dev/null
#* * * * * /usr/bin/checkdate > /dev/null
4,9,14,19,24,29,34,39,44,49,54,59 * * * * /etc/ntpdate -s
tick.usno.navy.mil > /dev/null 2>&1
With the result in the /usr/adm/check_date.log:
507VM vs 507 Physical
Fri Apr 5 23:40:10 CDT 2013
Fri Apr 5 23:40:34 CDT 2013
Added
4,9,14,19,24,29,34,39,44,49,54,59 * * * * /etc/ntpdate -s
tick.usno.navy.mil > /
to root's crontab and killed /etc/ntpd so that ntpdate will work.
507VM vs 507 Physical
Fri Apr 5 23:50:51 CDT 2013
Fri Apr 5 23:50:52 CDT 2013
507VM vs 507 Physical
Fri Apr 5 23:54:05 CDT 2013
Fri Apr 5 23:54:31 CDT 2013
507VM vs 507 Physical
Fri Apr 5 23:55:02 CDT 2013
507VM vs 507 Physical
Fri Apr 5 23:56:15 CDT 2013
Fri Apr 5 23:56:31 CDT 2013
...
Changed the checkdate logging to every 60 seconds to see the
result of the time drift and reset at 4, 9, 14 minutes etc...
The "-NN" times are normalized by subtracting VM time from "real"
time.
507VM vs 507 Physical
Sat Apr 6 00:00:00 CDT 2013
Sat Apr 6 00:00:05 CDT 2013 -5
507VM vs 507 Physical
Sat Apr 6 00:01:13 CDT 2013
Sat Apr 6 00:01:28 CDT 2013 -15
507VM vs 507 Physical
Sat Apr 6 00:02:12 CDT 2013
Sat Apr 6 00:02:33 CDT 2013 -21
507VM vs 507 Physical
Sat Apr 6 00:03:12 CDT 2013
Sat Apr 6 00:03:39 CDT 2013 -27
507VM vs 507 Physical
Sat Apr 6 00:04:11 CDT 2013
Sat Apr 6 00:04:44 CDT 2013 -33
507VM vs 507 Physical
Sat Apr 6 00:05:00 CDT 2013
Sat Apr 6 00:05:07 CDT 2013 -7
507VM vs 507 Physical
Sat Apr 6 00:06:13 CDT 2013
Sat Apr 6 00:06:28 CDT 2013 -15
507VM vs 507 Physical
Sat Apr 6 00:07:12 CDT 2013
Sat Apr 6 00:07:33 CDT 2013 -21
507VM vs 507 Physical
Sat Apr 6 00:08:12 CDT 2013
Sat Apr 6 00:08:39 CDT 2013 -27
507VM vs 507 Physical
Sat Apr 6 00:09:12 CDT 2013
Sat Apr 6 00:09:44 CDT 2013 -31
507VM vs 507 Physical
Sat Apr 6 00:10:00 CDT 2013
Sat Apr 6 00:10:06 CDT 2013 -6
507VM vs 507 Physical
Sat Apr 6 00:11:14 CDT 2013
Sat Apr 6 00:11:29 CDT 2013 -15
....
checkdate logging returned to every 10 minutes and ntpdate running
4,9,14,19,24,29,34,39,44,49,54,59 * * * * /etc/ntpdate -s
tick.usno.navy.mil > /dev/null 2>&1
ntpd killed
507VM vs 507 Physical
Sat Apr 6 06:50:22 CDT 2013
Sat Apr 6 06:50:23 CDT 2013
507VM vs 507 Physical
Sat Apr 6 07:00:22 CDT 2013
Sat Apr 6 07:00:22 CDT 2013
507VM vs 507 Physical
Sat Apr 6 07:10:22 CDT 2013
Sat Apr 6 07:10:22 CDT 2013
507VM vs 507 Physical
Sat Apr 6 07:20:22 CDT 2013
Sat Apr 6 07:20:22 CDT 2013
507VM vs 507 Physical
Sat Apr 6 07:30:22 CDT 2013
Sat Apr 6 07:30:22 CDT 2013
507VM vs 507 Physical
Sat Apr 6 07:40:22 CDT 2013
Sat Apr 6 07:40:22 CDT 2013
So: Why does ntpdate work to change the system clock when nptd does not?
Apr 7 01:16:57 507vm ntpd[7764]: ntpd 4.0.98h Tue Feb 18 02:25:48 PST 2003 (1)
Apr 7 01:16:57 507vm ntpd[7764]: precision = 7 usec
Apr 7 01:16:57 507vm ntpd[7764]: kern_enable is 1
Apr 7 01:16:57 507vm ntpd[7764]: configure: keyword "tinker" unknown, line ignored
Apr 7 01:16:57 507vm ntpd[7764]: configure: keyword "kod" unknown, line ignored
Apr 7 01:16:57 507vm ntpd[7764]: frequency initialized -141.205 from /etc/driftfile
# ntpdc
ntpdc> peers
remote local st poll reach delay offset disp
=======================================================================
=tick.usno.navy. 172.16.254.100 1 64 1 0.16805 21.588063 7.93750
ntpdc> peers
remote local st poll reach delay offset disp
=======================================================================
=tick.usno.navy. 172.16.254.100 1 64 1 0.16805 21.588063 7.93750
ntpdc> peers
remote local st poll reach delay offset disp
=======================================================================
=tick.usno.navy. 172.16.254.100 1 64 1 0.16805 21.588063 7.93750
ntpdc> peers
remote local st poll reach delay offset disp
=======================================================================
=tick.usno.navy. 172.16.254.100 1 64 3 0.07915 45.495814 3.93773
ntpdc> peers
remote local st poll reach delay offset disp
=======================================================================
=tick.usno.navy. 172.16.254.100 1 64 7 0.07915 45.495814 1.93822
ntpdc> peers
remote local st poll reach delay offset disp
=======================================================================
=tick.usno.navy. 172.16.254.100 1 64 7 0.07915 45.495814 1.93822
ntpdc> peers
remote local st poll reach delay offset disp
=======================================================================
=tick.usno.navy. 172.16.254.100 1 64 7 0.07915 45.495814 1.93822
ntpdc> peers
remote local st poll reach delay offset disp
=======================================================================
=tick.usno.navy. 172.16.254.100 1 64 17 0.06685 94.261869 0.93829
ntpdc>
--
Steve Fabac
S.M. Fabac & Associates
816/765-1670