I'm running KVM w/ centos 6.x.

My guest vm clocks are booting with a 1-2 second lag from their host. My clocksource for the host is ntp. My clocksource for the guest is "kvm-clock", but I need to run ntpd on the guest as well.

It takes roughly 3 minutes for ntpd to correct the time after boot. I'll see this in /var/log/messages

ntpd[1512]: time reset +1.217409 s

But, by this time, our application has already started and it doesn't handle the 1-2 sec time jump very well.

Is this clock difference between the host/guest normal? Is there a way to force the ntpd to set the time earlier in the boot process?


Solution 1:

If your application requires the clock to be synced, add ntp-wait to its init script before it is started. Usage is simple, but here is the man page.

EDIT: If you want to sync time as quickly as possible when booting the VM, before starting ntpd as a daemon, run sntp as explained in the documentation for Deprecating ntpdate.