Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How does one ensure that linux hosts, running on vmware infrastruction 3 or vmware 3 esxi remain in sync with the ntp server. I have found that a linux guest running under esx or esxi has a tendency to have the clock drift in the future.

How does one ensure that the time remains in sync with the time server? Do i have to deploy vmware tools on the linux host? and then sync the host to the ntp server, the guest with the host and with the ntp server?

share|improve this question
add comment

10 Answers

up vote 6 down vote accepted

That's a problem I encountered and sometimes the drifts are so large that the ntp service refused to sync.

I found that if you install the vmware tools on the guest, it will automatically sync its time against the host's time.

share|improve this answer
    
I've also found that I had to add clocksource=pit to the grub kernel bootline. –  Scott Jun 9 '09 at 20:03
add comment

Short Answer: proper kernel parameters and ntpd config

Long Answer: VMware has a best practices doc that is pretty good on this, http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006427

Note that it is somewhat contrary to some of the information in this thread. For instance, it is specifically recommended not to use the vmware-tools timesync feature anymore.

share|improve this answer
    
Different host/guest installs need a different combination of solutions, I'm afraid. I worked with a virtual box in another job that we just could not fix the timesync problem with, no matter what we tried. –  staticsan Jun 10 '09 at 6:03
add comment

Yes, installing vmware-tools for the clock sync tool is important, but might not be enough.

What has worked for me is adding the kernel boot parameter:

clock=pit notsc

This sets the clocksource to something vmware keeps updated, and disables the time sync counter.

Perhaps unrelated, but on recent enough kernels I always also append:

divider=10

which significantly reduces guest cpu utilization.

Both of these are also helpful with or without vmware tools are installed, and help keep the clocks more closely in sync (rather than a constant struggle between a quickly drifting clock and the vmware tools clock sync service).

share|improve this answer
add comment

Yes, you have to install vmware-tools on the VM client. Then you can set the box "synchronize guest time with host" button on the VM's Options screen.

share|improve this answer
add comment

There's an answer which is already selected (and it is the best answer, since vmware tools gives you so many other advantages), but another option is also to run regular ntpdate commands in the cron. This corrects your clock, however doesn't manage clock drift, but works in a pinch.

share|improve this answer
add comment

Be careful with ntpdate or rdate, it's usually not a wise idea to move the time the hard way, as many server applications depend on a continuous time.

Dovecot for instance, will just quit if it detects a large shift of time.

share|improve this answer
    
Also, never use ntpdate in conjunction with VMWare's own time sync facility. You can end up with VMWare making a significant drift-base connection after ntpdate has updating the clock making things as inaccurate as they were just in the other direction. –  David Spillett Jun 9 '09 at 17:53
add comment

If you are using a "tickless" kernel (2.6.22+ is by default IIRC) in the guests then clock drift is easier to manage. I have found that using NTP is more accurate than VMWare's own tool but I've not scientifically tested this.

To stop NTP simply giving up if heavy load or some other issue makes the clock drift too far (this much more rare with the newer kernels but can still happen) make sure you have the line "tinker panic 0" line at/near the top of your ntp.conf.

To be considerate, sync your host machines clock with public clocks and the VMs with the host - don't have all your VMs separately contacting public time servers.

Also: do not use VMWare's own clock guest sync at the same time as NTPD. The two will trip over each other leaving your VM's clock in an undefined and unreliable state.

share|improve this answer
add comment

Here's a good compilation of vmware timekeeping articles that have helped me in the past: http://blogs.vmware.com/kb/2009/02/new-timekeeping-articles.html

share|improve this answer
add comment

If you install the NTP daemon on your Linux guest as a client, it will periodically check and make sure your clocks do not drift in the long run. You needn't do any fancy host-guest syncing, because the server is just .. on the net. :)

share|improve this answer
1  
NTP in a VM very probably will NOT fix this problem. The problem with running as a VM is that you don't necessarily get a consistent number of ticks per cpu-second. Under these conditions, ntp will usually give up sync attempts fairly quickly. You either have to go the vmware-tools route, or do a crude 'rdate -s $SERVER' from cron to yank the clock around. –  David Mackintosh Jun 9 '09 at 15:29
add comment

This could be useful..

Guest kernel boot parameter:

 clock=pit
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.