Best practice for system clock sync on KVM host

14,244

Solution 1

Check what clocksource that you are using:

$ cat /sys/devices/system/clocksource/clocksource0/current_clocksource

Check which ones that are available:

$ cat /sys/devices/system/clocksource/clocksource0/available_clocksource

If you got a "kvm-clock" entry in "available_clocksource" try to use it by setting kernel parameter:

clocksource=kvm-clock

Pretty good document here (general) why it's so tricky to get the clock right.

Solution 2

http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/chap-Virtualization-KVM_guest_timing_management.html

Solution 3

A chrony instance per VM with short interval poll updates from local NTP server(s) seems to be the only viable-reasonable way to go.

Although chrony can broadcast time updates across LAN, it doesn't support listening to such updates and there're no plans to add it. Unicast is recommended with such a comment: "…

Even with very modest hardware, an NTP server can serve time to hundreds of thousands of clients using the ordinary client/server mode.

…"

Share:
14,244

Related videos on Youtube

Tauren
Author by

Tauren

Software engineer

Updated on September 17, 2022

Comments

  • Tauren
    Tauren over 1 year

    I have an Ubuntu 9.10 server running as a KVM host with ntpd installed on it. The host system has the correct system time. At the moment I only have a single KVM guest, also Ubuntu 9.10 server. I do not have ntpd installed on it, and I just discovered the clock is about 6 minutes slow. It wasn't that way when it was installed about a month ago.

    I thought that I only needed to keep the host clock synchronized and that the guests used the host clock. But maybe that is a memory from using OpenVZ. I believe the reasoning was related to only the host could modify the physical system clock.

    Is running ntpd on both the host and all the guests the correct thing to do? Or is there something else that is preferred? How should I keep the guest clocks in sync?

  • Tauren
    Tauren about 14 years
    @rkthkr: looks like current_clocksource is already set to kvm-clock, but the guest is still minutes off from the host.
  • delimiter69
    delimiter69 almost 6 years
    Given that this comment is 8 years old,I don't really trust it it still truly an issue.