Ntp things : synchronize your date … with Xen

{jcomments on}To keep your system clock accurate, it exists the ntp protocol : « NTP« .

You can manage and update your system clock by hand, thanks to the command « ntpdate »

# date; ntpdate ntp.ubuntu.com ntp.univ-lyon1.fr ; date
Tue May 5 22:38:16 CEST 2009
5 May 22:38:17 ntpdate[12966]: step time server offset -266.989213 sec
Tue May 5 22:33:50 CEST 2009

Or you can let a deamon do that work for you.

# apt-get install ntp

The configuration file for the daemon is /etc/ntp.conf. I just added two servers to maximize the accuracy.

# echo -e "server canon.inria.fr\nserver ntp.univ-lyon1.fr"  >> /etc/ntp.conf
# /etc/init.d/ntp restart

It’s really simple to manage your system time, but I had trouble for two days with ntpdate. I couldn’t syncrhonize my date, even if the command told me « step time server blabla offset -blabla ». Really annoying, and fortunately, I remember my system was a Xen client. So I searched this way.

You have to say : « my Xen client date is independant from the host » :

# set independent_wallclock
# echo 1 > /proc/sys/xen/independent_wallclock

Then you can run  ntpdate, or let your deamon synchronize the system. It works!!!!

Finally, I found many useful tips while trying to correct the xen issue.

  • when the command ntpdate runs successfully, you may notice it says sometime « step time server », and sometime « adjust time server ». There is a BIG difference between these sentences. The first case indicates ntpdate has used the settimeofday() routine when the second case indicates the time was updated with adjtime() system call. (man ntpdate)
  • To evaluate your offset with real time, and not change your system date, just run ntpdate with the option -d. This debug mode won’t modify your date.

Hope this will help someone.


Sources for the Xen bug :

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *