Tuesday 8 June 2010

What's the time?

I've been having issues with a number of CentOS hosts not holding the correct time - they seem to be drifting incessantly, despite the fact that they should be syncing to a number of NTP servers. Looking at the output of an ntpdate, I get the following error:

[root@nx-01 ~]# ntpdate
8 Jun 09:29:09 ntpdate[4267]: no servers can be used, exiting

Although the log messages are showing that the server is quite happily synchronised to its NTP peers:

Jun 8 09:08:20 nx-01 ntpd[1698]: synchronized to LOCAL(0), stratum 10
Jun 8 09:09:25 nx-01 ntpd[1698]: synchronized to 77.75.105.150, stratum 2
Jun 8 09:13:41 nx-01 ntpd[1698]: synchronized to 62.84.188.34, stratum 2

Forcing ntp to update by shutting down the daemon and passing a server as an argument to ntpdate also has no effect - the drift remains.

After some head scratching, I've come across the root cause of this issue. The servers in question are actually DomU instances on a Xen host, and by default they attempt to synchronize their clocks with the Dom0. I've since updated my Dom0's to use correct NTP settings, but for reference if you need to break this dependency you can do it with the following command:

echo 1 > /proc/sys/xen/independent_wallclock

To make it permanent you can append that line to the bottom of /etc/rc.d/rc.local.

No comments: