We help IT Professionals succeed at work.

Time syschronisation probelm

jaisonshereen
on
872 Views
Last Modified: 2012-08-14
I have installed Vmware tools 4 linux vms and enabled time sychronisation

But i couldnt find all the time of 4 vms are same when i fired the "date" command.

Please help me !
Comment
Watch Question

I have been fighting my ESX server for about a year with time sync on linux vm's and have been unsuccessful with with vmtools. I ended up creating a script that ran ntpdate every hour to keep my linux servers in sync.

I would be interested to know a resolve for this too.

Author

Commented:
Will it be this the cause ?


You can synchronize the time in the guest operating system with time on the host operating system only when the time in the guest operating system is earlier than the time set in the host.


Did u checked this also?
You should synchronize the ate with an NTP server

Author

Commented:
how to synchronize with NTP server?
You will need to install ntpdate on your linux box. you can then either run the command ntpdate  or do what i did a create a script that you place in cron to run at a regular interval.

You will then need to find a reliable ntp server. Search the net and you will find them everywhere

Author

Commented:
Can u give me an IP ? i couldn't find it in net ..
where/how i can install ntpdate ?
so after install i execute this command ..
ntpdate  in all servers.
Will all the servers become sync?



Top Expert 2008

Commented:
Time synchronization  inside a virtual environment can be tricky. By using VMware Tools it will only catchup time if the VM time is too slow.

Using a scheduled ntpdate might be good enough, depending on how precise timing you need inside your VM.

Lowering the HZ of your kernel will usually help quite a bit for fixing the clock inside your VM. Using the following parameters (for 32bit guests) will also help: clocksource=pit noapic nolapic nosmp

You do not mention what linux distros you're using. For precise timing you might want to use the VMware Descheduled time service (you need a supported guest os): http://www.vmware.com/pdf/vi3_esx_vmdesched.pdf 

Also see this document for details about the timekeeping challenges: http://www.vmware.com/pdf/vmware_timekeeping.pdf

Lars
Duncan RoeSoftware Developer
CERTIFIED EXPERT

Commented:
I had the problem of VMWare clock running fast at work. It's all fine now; the solution is in 2 parts:

1. Disable VMWare tools' attempts to fix the time - it only make it worse
2. Refresh the time every minute from a "reasonably" accurate source (standard PC running Linux as native O/S)

Item 1 requires that you have or obtain a binary editor. Edit the VNMWare daemon executable, replacing every occurrence of "settimeofday" with "gettmeofday". The 2 functions have identical signatures so the code keeps running, it just stops messing up your time.

Item 2 is implemented by having a once per minute cron job run netdate (available from http://linux.maruhn.com/sec/netdate.html). Only give netdate a single host name on its command line, so it has no option but to get time from that host.

Do that on all your 4 systems and they should stay in sync.

Author

Commented:
For Item 1 : Can i go ahead an uninstall vmware tools ?
For Item 2 : Please help me . Please explain me in detail

Author

Commented:
i can see lots of rpm netdate files ..which one i have to use ?

Author

Commented:
Will this be a solution?


 Vmware Time Sync

If you want to completely disable time synchronization in the guest, open the virtual machine's configuration file (.vmx) in a text editor and set the following options to FALSE.

tools.syncTime
time.synchronize.continue
time.synchronize.restore
time.synchronize.resume.disk
time.synchronize.shrink

If instead you want the guest to have a constant offset from real time as maintained by the host, you can use the rtc.diffFromUTC option, or simply set the CMOS TOD clock time from the virtual machine's BIOS setup screen or from within the guest operating system. In Microsoft Windows, setting the system time automatically updates the CMOS clock.

If you want, you can force the CMOS TOD clock's offset to be initialized to a specific value at power on. To do so, set the option rtc.diffFromUTC in the virtual machine's .vmx configuration file to a value in seconds. For example, setting rtc.diffFromUTC = 0 sets the clock to UTC at power on, while setting rtc.diffFromUTC = -25200 sets it to Pacific Daylight Time, seven hours earlier than UTC. The guest operating system can still change the offset value after power on by writing directly to the CMOS RT

Author

Commented:
i did this ...

http://kbase.redhat.com/faq/FAQ_43_9259.shtm



do the restarting guest is mandatory?
Top Expert 2008

Commented:
That solution will work if the clock inside your guest is too slow: Linux Guest Clock Runs Slowly on ESX Server 3

If the clock is running too quickly see: Clock in a Linux Guest Runs More Slowly or Quickly Than Real Time

Lars

Author

Commented:
where i need to edit this? in guest or host or both ?
Top Expert 2008

Commented:
Which one of the solutions are you refering to now?

Author

Commented:
In my four VMs   2 are going faster than esx and 2 are going slower than ESX.

So i refered the link :

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1420

Here i couldnt find etc/lilo.conf  ..but i can see grub.conf

but i found those in guest and host .. so which i need to edit ?

In the provided link..i seen some differences in configuration:

One is to add clock=pit or clock=pit nosmp noapic nolapic

and i coulnt find lilo.conf ...in my server..is this mandatory to edit ...?

and what else i need to edit ?

Author

Commented:
do i need to change timer.max.hardperiod as per ur link : http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2219

if so which value i have to put ?

i am pretty confused now

and ..moreover editing these values ..will not make any harm ..right?
Top Expert 2008

Commented:
You should only add those kernel parameters inside your guest OS. If your kernel is 2.6.17 or newer you should use clocksource instead of clock even though clock is still working in many distros.

Changing  timer.max.hardperiod will help your too quick guests if you can't lower their HZ which is the optimal solution. We still don't know what linux distros you're using, but some of the later RHEL editions have kernels where you can lower the HZ easily without recompiling the kernel by using the kernel parameter divider=10.


Lars

Author

Commented:
I am using centOS and

uname -a

Linux server.domain.com 2.8.16-53.e15 #1 SMP Mon Nov 12 ..... X86_64 X86_64 x86_64 GNU/Linux


Author

Commented:
So is this 64 bit ?

Author

Commented:
Kindly request me if anything else you need ?
Duncan RoeSoftware Developer
CERTIFIED EXPERT

Commented:
My solution does not rely on any cooperation from VMWare. We had a commercial deadline to meet, and we could not afford to await possible answers. The host, by the way, is Windows XP.
The netdate URL I gave you is for source: you build and install yourself. We run Slackware so had it anyway. I can't check the crontab entry right now because I'm off work for a few weeks following radical prostatectomy but from memory it looks like:

* * * * * /usr/sbin/netdate linuxhost 1>/dev/null

In this example, "linuxhost" is the name of some PC running linux native. The guests will sync their time to whatever it is on that PC. Windows systems don't offer that service (on port 37) so that's why you have to use linux. linuxhost might run ntpd - nothing else needs to.

You should run "crontab -e" as root and insert this line.

I can't advise you on which RPM to use as I hardly ever use them myself. But I guess anything with i386 in its name will probably be OK.

Quite possibly the suggestion to change the config file in http:#22083782 will work for you instead of editing the executable as I did. You can check if this has worked as follows:
Install the cron netdate line. Now keep an eye on the time for a few minutes: in an xterm or other shell window type "watch :". You will see the time ticking over every 2 seconds in the top right hand corner of the window. Make sure it changes smoothly: you may see the odd correction as the minute changes (because netdate ran) but if the time jumps around at other times then VMWare daemon is still messing with it.

Good luck and post if you have any further queries
Duncan RoeSoftware Developer
CERTIFIED EXPERT

Commented:
Some new posts while I was typing. You need an RPM with x86_64 in its name instead of i386 (you may not have the 32-bit glibc libraries installed to run i386 binaries - I have them on my 64-bit system but after a lot of manual installation). Building from source will always work (providing you have the compiler toolchain installed).
Duncan RoeSoftware Developer
CERTIFIED EXPERT

Commented:
Note the solution I posted will work for slower or faster guest.

Author

Commented:
can i do think ticking in vmware tools using a command in terminal?

Author

Commented:
can i do this ticking using mouse click  in vmware tools window using a command in terminal?
Top Expert 2008
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Duncan RoeSoftware Developer
CERTIFIED EXPERT

Commented:
Sorry jaisonshereen, I don't understand what you mean by "ticking using mouse click". "watch" is a standard command to repeat *any* shell command every 2 seconds (you can vary that time - 2s is just the default). So I could have suggested you do "watch date" - but watch always displays the time anyway so I suggested "watch :": ":" is the shell no-op command.

Just follow my previous suggestions and everything will be fine. I have found the drift is too big for any other mechanism to cope.

Author

Commented:
i mean .....is it possible use a bunch of commands in terminal instead of using clicking on the time synchronization check box using mouse clicks?

So that i can put those commands to run as a crontab entry !

Duncan RoeSoftware Developer
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Duncan RoeSoftware Developer
CERTIFIED EXPERT

Commented:
Sorry - last link above should be http:#22075733
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.