You are not logged in.

#1 2017-01-25 13:47:02

Gregosky
Member
From: UK
Registered: 2013-07-26
Posts: 173

[Solved] ntpd on kvm guest - rtc updated, but localtime not

Hi all,

I have spent a few nights on this now and could not find the straight answer. The only suggestion was to run

ntpdate -b 3.arch.pool.ntp.org

from time to time. I'm now also testing

tinker panic 0

in ntp.conf - though not sure if this should be the right solution.

So in short - I have set up my private vps where I wanted to collect some timeseries for later analysis. So I have set the server up as I would my other machines (all running arch) and I installed ntpd on top and left the server running assuming all is fine. Then after a few weeks I started seeing my time series data is not accurate and that was because of time shift when compared to actual extract from the source. First step to debug was to see if ntpd service is running/communicating (it was) and next to see what timedatectl is showing. Time was off almost 12 seconds.

Started reading about this and found that the fast way to allow ntpd to set the correct time is to run

ntpdate -b 3.arch.pool.ntp.org

- so I have stopped ntpd service, executed command a two times in couple of minutes interval and started ntpd again. And all seemed to be fine - time seemed to be synched, output of timedatectl looked ok.

But after a few days I logged in and checked time again and this is what I see:

Local time: Wed 2017-01-25 13:35:35 UTC
Universal time: Wed 2017-01-25 13:35:35 UTC
RTC time: Wed 2017-01-25 13:35:32
Time zone: UTC (UTC, +0000)
Network time on: no
NTP synchronized: yes
RTC in local TZ: no

so the time is again starting to drift and I again have to run ntpdate... which seems to make whole idea of ntpd not making much sense.

I'm lost now, would appreciate if somebody could shed some light...

Some further info:
Basing on this article: https://access.redhat.com/documentation … ement.html

cat /proc/cpuinfo | grep constant_tsc

Above gives some output (according to article that means `CPU has the constant Time Stamp Counter`)

KVM modules are loaded:

lsmod | grep virtio
virtio_net             32768  0
virtio_scsi            20480  4
scsi_mod              159744  4 sd_mod,virtio_scsi,libata,sr_mod
virtio_pci             24576  0
virtio_blk             20480  0
virtio_ring            20480  4 virtio_blk,virtio_net,virtio_scsi,virtio_pci
virtio                 16384  4 virtio_blk,virtio_net,virtio_scsi,virtio_pci

Last edited by Gregosky (2017-01-26 21:30:49)

Offline

#2 2017-01-25 15:08:05

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,740

Re: [Solved] ntpd on kvm guest - rtc updated, but localtime not

Can you try timedatectl set-ntp true   and then post the output of timedatectl   ?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2017-01-25 15:15:10

Gregosky
Member
From: UK
Registered: 2013-07-26
Posts: 173

Re: [Solved] ntpd on kvm guest - rtc updated, but localtime not

Hi ewaller,

Output below:

Local time: Wed 2017-01-25 15:14:21 UTC
Universal time: Wed 2017-01-25 15:14:21 UTC
RTC time: Wed 2017-01-25 15:14:19
Time zone: UTC (UTC, +0000)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no

Offline

#4 2017-01-25 15:17:40

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,740

Re: [Solved] ntpd on kvm guest - rtc updated, but localtime not

Okay, that turned on "Network time on: yes"; let's see if that helps.
BTW, I see you are in the UK, so this might make sense, but did you want to use UTC as your timezone?

Edit:  Oh, also, are you using NTP merely to synchronize your time? or are you intending to be a NTP server as well?

Last edited by ewaller (2017-01-25 15:19:10)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2017-01-25 15:33:23

Gregosky
Member
From: UK
Registered: 2013-07-26
Posts: 173

Re: [Solved] ntpd on kvm guest - rtc updated, but localtime not

At the moment I removed NTP server capability (in hope this would remove additional element that maybe was contributing to my problem). As to UTC - I symlinked UTC to localtime intentionally (though might rethink it once have more time on working on my importer :-) )

Thanks ewaller, so I'll probably need to wait for couple of days to see if time keeps drifting, would you think 'timedatectl set-ntp true' could be the case?

Offline

#6 2017-01-25 16:47:57

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,740

Re: [Solved] ntpd on kvm guest - rtc updated, but localtime not

Yes.  What is more, now your output looks like mine -- except the timezone wink


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#7 2017-01-26 00:13:53

Gregosky
Member
From: UK
Registered: 2013-07-26
Posts: 173

Re: [Solved] ntpd on kvm guest - rtc updated, but localtime not

Looked into man (should have done this first) it seems when setting 'timedatectl set-ntp true' will result in systemd-timesyncd.service started and ntpd.service stopped. I wonder if one is better than the other? I also can't now see ntp port opened when running netstat...?

--- EDIT ---

Ok, I see the difference. Indeed it seems systemd-timesyncd will fit better my needs. I'll keep an eye if rtc keeps drifting!

Last edited by Gregosky (2017-01-26 00:21:19)

Offline

#8 2017-01-26 01:32:39

rsmarples
Member
Registered: 2009-05-12
Posts: 287

Re: [Solved] ntpd on kvm guest - rtc updated, but localtime not

ntpd on kvm guest

Why?

The hypervisor should sync it's clock and the guests use that clock.

Offline

#9 2017-01-26 21:17:08

Gregosky
Member
From: UK
Registered: 2013-07-26
Posts: 173

Re: [Solved] ntpd on kvm guest - rtc updated, but localtime not

@rsmarples - On the internet people seem to be divided between those who believe ntp should not be used within guest system and those who say the opposite. I have had been reading through opinions on stack, ntp mailing lists, ubuntu forums, vmware and other. And all reliable sources of information (this unfortunately does not include 90% opinions people leave on the internet) point that when it comes to time management ntp is probably the most reasonable (and cheap) option and as such should be used within guest systems.

But to be honest I did not have to read through all of this to know I must use ntp-like solution since my hosting provider does not give any guarantee that hardware clock is synchronised to any reliable time source. I was not surprised when came accross their (vps provider) official article where they point to ntp-like solutions as a must-have.

@ewaller - day 1 and all servers seem to show rtc and localtime in synch. Good start - and fingers crossed it won't start drifting!

--- EDIT ---
I'll mark this thread as closed. My understanding was that ntp would update hardware clock from time to time in order to keep it in sync. It seems that may not be the case and that RTC could be updated as rarely as at every shutdown. (ref. http://tldp.org/HOWTO/Clock-2.html)

My take-away from this though is that systemd-timesyncd seems to be more than enough for my needs. Thanks @ewaller!

--- EDIT ---

5 days later time is in synch and RTC is still not drifting.

Last edited by Gregosky (2017-01-29 23:48:24)

Offline

Board footer

Powered by FluxBB