有的朋友在使用VMware产品时,可能会遇到虚机时间不准确的问题,在着手解决此问题前,请阅读此文档:
http://www.vmware.com/pdf/vmware_timekeeping.pdf
适用范围:VMware ESX3/ESXi3.5;VMware Workstation 6.5
该文档详细的讲述了为何虚机的时间为何会不准确,针对此问题VMware提供了以下解决方案:
1、虚机的操作系统为Microsoft旗下OS,那么仅需安装VMware Tools就可以了,虚机的系统会利用VMware Tools读取Host的硬件时钟进行同步和校准。如此一来,只要Host的时钟不出问题,那么虚机的时间就不会出现问题。
2、对于虚机是类Unix操作系统,请参考以下的文章:
"Timekeeping best practices for Linux"
http://kb.vmware.com/kb/1006427
基本上的意思是:针对不同的发行版本系统,在引导内核的指令中加入不同的参数来使用Virtual Hardware Clock来进行时间的同步及校准, 或者使用NTP,VMware Tools等等不同的方法来进行Guest OS的时间同步及校准。
这是针对不同的OS及版本需要加入的参数列表
----------------------------------------------------------------------------------------------------------
Linux Timekeeping Best Practice
Notes:
" When both SMP and UP kernels are available, they must be applied to the appropriate SMP and UP virtual machines, otherwise a mismatch may cause time to drift.
" The recommended kernel parameters must be added to the kernel parameters already configured by the distribution.
32bit Kernels
Linux Flavor Version Kernel Parameters Notes
RHEL
RHEL 5.4 No additional kernel parameters required.
See the note below about the optional use of divider=10.
RHEL 5.3 divider=10 clocksource=acpi_pm
RHEL 5.2 divider=10 clocksource=acpi_pm
RHEL 5.1 divider=10 clocksource=acpi_pm
RHEL 5.0 clocksource=acpi_pm
RHEL 4.8 clock=pmtmr divider=10
RHEL 4.7 clock=pmtmr divider=10
RHEL 4.6 clock=pmtmr
RHEL 4.5 clock=pmtmr
RHEL 4.4 clock=pmtmr
RHEL 4.3 clock=pmtmr
RHEL 4.2 clock=pmtmr
RHEL 4.1 clock=pmtmr
RHEL 4.0 clock=pmtmr
RHEL 3 (All updates) No additional kernel parameters required.
RHEL 2.1 No additional kernel parameters required.
Redhat
Redhat 9.0 No additional kernel parameters required.
Redhat 8.0 No additional kernel parameters required.
Redhat 7.3 No additional kernel parameters required.
Redhat 7.2 No additional kernel parameters required.
Redhat 7.1 No additional kernel parameters required.
Redhat 7.0 No additional kernel parameters required.
Redhat 6.2 No additional kernel parameters required.
SLES
SLES 11 No additional kernel parameters required.
SLES 10 SP3 on ESX 3.0.x and earlier clock=pmtmr
SLES 10 SP3 on ESX 3.5 and later Use a VMI enabled kernel.
SLES 10 SP2 on ESX 3.0.x and earlier clock=pmtmr
SLES 10 SP2 on ESX 3.5 and later Use a VMI enabled kernel.
SLES 10 SP1 clock=pmtmr
SLES 10 clock=pmtmr or clock=hpet* * AMD Rev F Opteron processors
SLES 9 (All updates) clock=pmtmr
SLES 8 No additional kernel parameters required.
SLES 7 No additional kernel parameters required.
SLED
SLED 11 No additional kernel parameters required.
SLED 10 clock=pmtmr
SLED 9 clock=pmtmr
Suse Linux
Suse Linux 10.3 clocksource=acpi_pm
Suse Linux 10.2 clocksource=acpi_pm
Suse Linux 10.1 clock=pmtmr
Suse Linux 10 clock=pmtmr
Suse Linux 9.3 clock=pmtmr
Suse Linux 9.2 clock=pmtmr
Suse Linux 9.1 clock=pmtmr
Suse Linux 9.0 Remove desktop kernel command line parameter.
Suse Linux 8.2 No additional kernel parameters required.
Suse Linux 8.1 No additional kernel parameters required.
Suse Linux 8.0 No additional kernel parameters required.
Suse Linux 7.3 No additional kernel parameters required.
Ubuntu
Ubuntu 9.10 No additional kernel parameters required.
Ubuntu 9.04 with kernel 2.6.28-7.18 or later on ESX 4.0 or later No additional kernel parameters required.
Ubuntu 9.04 with kernel prior to 2.6.28-7.18 on ESX 4.0 or later Avoid using if possible. May cause guest operating system to stop responding.
Ubuntu 8.10 with kernel 2.6.27-12.28 or later on ESX 4.0 or later No additional kernel parameters required.
Ubuntu 8.10 with kernel prior to 2.6.27-12.28 on ESX 4.0 or later Avoid using if possible. May cause guest operating system to stop responding.
Ubuntu 8.10 clocksource=acpi_pm
Ubuntu 8.04 on ESX 3.5 and later Use a VMI enabled kernel.
Ubuntu 8.04 on ESX 3.0.x and earlier clocksource=acpi_pm
Ubuntu 7.10 clocksource=acpi_pm
Ubuntu 7.04 clocksource=acpi_pm
Ubuntu 6.10 clock=pmtmr
Ubuntu 6.06 clock=pmtmr
Ubuntu 5.10 clock=pmtmr
Ubuntu 5.04 clock=pmtmr
Mandriva
Mandriva Corporate Desktop 4.0 clock=pmtmr
Mandriva Corporate Server 4 clock=pmtmr
Mandriva Linux 2008 clocksource=acpi_pm
Mandriva Linux 2007 clock=pmtmr
Mandriva Linux 2006 clock=pmtmr
Mandrake 10.1 Does not support pmtmr . Avoid using if possible.
Mandrake 10 Does not support pmtmr . Avoid using if possible.
Mandrake 9.2 No additional kernel parameters required.
Mandrake 9.1 No additional kernel parameters required.
Mandrake 9.0 No additional kernel parameters required.
Mandrake 8.2 No additional kernel parameters required.
Mandrake 8.1 No additional kernel parameters required.
Mandrake 8.0 No additional kernel parameters required.
Turbolinux
Turbolinux 10 Desktop Does not support pmtmr. Avoid using if possible.
Turbolinux 10 Server clock=pmtmr
Turbolinux Enterprise 8 No additional kernel parameters required.
Turbolinux Workstation 8 No additional kernel parameters required.
Turbolinux 7.0 No additional kernel parameters required.
Asianux
Asianux 3.0 SP1 No additional kernel parameters required.
Use kernel 2.6.18-53.17AXS3 or later.
Asianux 3.0 divider=10 clocksource=acpi_pm
CentOS
CentOS 5.4 No additional kernel parameters required.
See the note below about the optional use of divider=10.
CentOS 5.3 divider=10 clocksource=acpi_pm
CentOS 5.2 divider=10 clocksource=acpi_pm
CentOS 5.1 divider=10 clocksource=acpi_pm
CentOS 5.0 clocksource=acpi_pm
CentOS 4.8 clock=pmtmr divider=10
CentOS 4.7 clock=pmtmr divider=10
CentOS 4.6 clock=pmtmr
CentOS 4.5 clock=pmtmr
CentOS 4.4 clock=pmtmr
CentOS 4.3 clock=pmtmr
CentOS 4.2 clock=pmtmr
CentOS 4.1 clock=pmtmr
CentOS 4.0 clock=pmtmr
Oracle
OEL 5.4 No additional kernel parameters required.
See the note below about the optional use of divider=10.
OEL 5.3 divider=10 clocksource=acpi_pm
OEL 5.2 divider=10 clocksource=acpi_pm
OEL 5.1 divider=10 clocksource=acpi_pm
OEL 5.0 clocksource=acpi_pm
OEL 4.8 clock=pmtmr divider=10
OEL 4.7 clock=pmtmr divider=10
OEL 4.6 clock=pmtmr
OEL 4.5 clock=pmtmr
Debian
Debian 5.0 No additional kernel parameters required.
Debian 4.x divider=10 clocksource=acpi_pm
64bit Kernels
Linux Flavor Version Kernel Parameters Notes
RHEL
RHEL 5.4 No additional kernel parameters required.
See the note below about the optional use of divider=10.
RHEL 5.3 notsc divider=10
RHEL 5.2 notsc divider=10
RHEL 5.1 with RHSA-2007:0993-13 notsc divider=10
RHEL 5.1 without RHSA-2007:0993-13 notsc
RHEL 5.0 No additional kernel parameters required.
RHEL 4.8 notsc divider=10
RHEL 4.7 notsc divider=10
RHEL 4.6 notsc
RHEL 4.5 notsc
RHEL 4.4 notsc
RHEL 4.3 notsc
RHEL 4.2 notsc
RHEL 4.1 Does not support notsc . Avoid using if possible.
RHEL 4.0 Does not support notsc . Avoid using if possible.
RHEL 3 Update 9 with RHSA-2008-0973 disable_lost_ticks
RHEL 3 through Update 8 Has no workaround for lost tick overcompensation. Avoid using if possible.
SLES
SLES 11 No additional kernel parameters required.
SLES 10 SP3 on ESX 3.5 and later No additional kernel parameters required.
SLES 10 SP3 on ESX 3.0.x and earlier notsc
SLES 10 SP2 on ESX 3.5 and later No additional kernel parameters required.
SLES 10 SP2 on ESX 3.0.x and earlier notsc
SLES 10 SP1 notsc
SLES 10 notsc
SLES 9 with kernel version 2.6.5-7.312 or later ignore_lost_ticks
SLES 9 with kernel version 2.6.5-7.311 or earlier Has no workaround for lost tick overcompensation. Avoid using if possible.
SLED
SLED 11 No additional kernel parameters required.
SLED 10 clock=pmtmr
Suse Linux
Suse Linux 10.3 clocksource=acpi_pm
Suse Linux 10.2 notsc
Suse Linux 10.1 notsc
Suse Linux 10 notsc
Suse Linux 9.3 notsc
Suse Linux 9.2 Does not support notsc. Avoid using if possible.
Suse Linux 9.1 Does not support notsc. Avoid using if possible.
Ubuntu
Ubuntu 9.10 No additional kernel parameters required.
Ubuntu 9.04 with kernel 2.6.28-7.18 or later on ESX 4.0 or later No additional kernel parameters required.
Ubuntu 9.04 with kernel prior to 2.6.28-7.18 on ESX 4.0 or later Avoid using if possible. May cause guest operating system to stop responding.
Ubuntu 8.10 with kernel 2.6.27-12.28 or later on ESX 4.0 or later No additional kernel parameters required.
Ubuntu 8.10 with kernel prior to 2.6.27-12.28 on ESX 4.0 or later Avoid using if possible. May cause guest operating system to stop responding.
Ubuntu 8.10 clocksource=acpi_pm
Ubuntu 8.04 with kernel 2.6.24-24.52 or later on ESX 4.0 or later No additional kernel parameters required.
Ubuntu 8.04 with kernel prior to 2.6.24-24.52 on ESX 4.0 or later Avoid using if possible. May cause guest operating system to stop responding.
Ubuntu 8.04 clocksource=acpi_pm
Ubuntu 7.10 clocksource=acpi_pm
Ubuntu 7.04 No additional kernel parameters required.
Ubuntu 6.10 notsc
Ubuntu 6.06 notsc
Ubuntu 5.10 notsc
Ubuntu 5.04 Does not support notsc. Avoid using if possible.
Mandriva
Mandriva Corporate Desktop 4.0 notsc
Mandriva Corporate Server 4 notsc
Mandriva Linux 2008 clocksource=acpi_pm
Mandriva Linux 2007 notsc
Mandriva Linux 2006 notsc
Mandrake Linux 10.1 Does not support notsc. Avoid using if possible.
Turbolinux
Turbolinux 10 Desktop Does not support notsc. Avoid using if possible.
Turbolinux 10 Server Does not support notsc. Avoid using if possible.
Asianux
Asianux 3.0 SP1 No additional kernel parameters required.
Use kernel 2.6.18-53.17AXS3 or later.
Asianux 3.0 notsc
CentOS
CentOS 5.4 No additional kernel parameters required.
See the note below about the optional use of divider=10.
CentOS 5.3 notsc divider=10
CentOS 5.2 notsc divider=10
CentOS 5.1 notsc
CentOS 5.0 No additional kernel parameters required.
CentOS 4.8 notsc divider=10
CentOS 4.7 notsc divider=10
CentOS 4.6 notsc
CentOS 4.5 notsc
CentOS 4.4 notsc
CentOS 4.3 notsc
CentOS 4.2 notsc
CentOS 4.1 Does not support notsc. Avoid using if possible.
CentOS 4.0 Does not support notsc. Avoid using if possible.
Oracle
OEL 5.4 No additional kernel parameters required.
See the note below about the optional use of divider=10.
OEL 5.3 notsc divider=10
OEL 5.2 notsc divider=10
OEL 5.1 notsc
OEL 5.0 No additional kernel parameters required.
OEL 4.8 notsc divider=10
OEL 4.7 notsc divider=10
OEL 4.6 notsc
OEL 4.5 notsc
Debian
Debian 5.0 No additional kernel parameters required.
Debian 4.x notsc
Recommended Configurations
The following configurations are expected to have the best timekeeping behavior:
" RHEL 5.4 32bit or 64bit running on ESX 3.5 or later
" SLES 10 SP2 or later 32bit or 64bit running on ESX 3.5 or later
" SLES 11 32bit or 64bit running on ESX 4.0 or later
" Ubuntu 8.04 32bit running on ESX 3.5 or later
" Ubuntu 8.04, 8.10, or 9.04, 32bit or 64bit running on ESX 4.0 or later
Among different version of RHEL 5 and RHEL 4, RHEL 5.4 or later has the best timekeeping behavior. For older versions, those supporting divider=10 have better timekeeping behavior than those that do not.
----------------------------------------------------------------------------------------------------------
这是针对两种不同的BootLoader的参数修改方法
----------------------------------------------------------------------------------------------------------
Editing Kernel Configuration
Kernel command line parameters are specified in the /etc/lilo.conf or /boot/grub/grub.conf file, depending on your choice of boot loader.
For LILO, put the kernel command line parameters at the end of the "append" line. For example, if the append line looks like:
append="resume=/dev/hda6 splash=silent"
and you want to add "clock=pmtmr divider=10" the updated text is:
append="resume=/dev/hda6 splash=silent clock=pmtmr divider=10"
Remember to run /sbin/lilo after editing lilo.conf , so that your edits take effect.
For GRUB, put the kernel command line parameters at the end of the "kernel" line. For example if the kernel line looks like:
kernel /vmlinuz-2.6.18 ro root=/dev/hda2
and you want to add "clock=pmtmr divider=10" the updated text is:
kernel /vmlinuz-2.6.18 ro root=/dev/hda2 clock=pmtmr divider=10
For additional information about working with boot loaders, see your Linux distribution's documentation.
---------------------------
翻译过来大致是:
1、对于使用lilo这种Boot Loader而言,应该修改/etc/lilo.conf文件
加入前表列举的Kernel Parameters(内核参数),然后执行一次/sbin/lilo来使配置生效
2、对于使用GRUB这种Boot Loader而言,应该修改/boot/grub/grub.conf文件
加入前表列举的Kernel Parameters(内核参数)即可。
(注:如果是RHEL,CentOS的话应该是/boot/grub/menu.lst文件。为何?请ls -la /boot/grub/看看)
不过,不同的发行版本可能会有不同的引导修改方式,具体情况请查看该发行版本的相关文档。
----------------------------------------------------------------------------------------------------------
另外:网上还有一种非官方的解决办法:
安装VMware Tools之后,在内核引导中加入noapci acpi=off clock=pit这三个参数。经过我的测试,此法是不恰当的。因为ACPI不仅仅是一个硬件时钟管理的程序(称之为程序是否恰当?),更是一个电源管理程序,如果将acpi关闭,会出现Guest OS在poweroff之后还处于一种挂起(system halted)的状态,你需要手动去关闭虚机的电源才能彻底的关闭虚机。
如果使用此法来解决虚机时间问题的话,个人测试出来正确的参数应该是:
noapci acpi=off clock=pit apm=power-off
这样才能保证系统正常关机且大致保持Guest OS时间的准确性,我在一台虚机中使用此法来解决时间问题时,Guest OS时间始终有1~5分钟的误差。
题外话:
apm=power-off参数与apmd服务没有你想像中的那么关系密切,如果你不需要,你可放心将apmd服务禁用。