VMware ESX/ESXi Server与虚拟机时间同步问题

公司使用了VMware Vsphere 4.1,虚拟机是windows server 2003,并加入了网域中,最近发现虚拟机的本机时间会比DC慢了几分钟,并且该虚拟机所在的ESXi主机也比DC慢了一些,怀疑虚拟机同步了ESXi主机时间,影响了虚拟机的本地时间(虚拟机会周期性与ESXi主机进行时间同步),于是在虚拟机的Vmware tools的选项中,禁止了与ESXi主机的时间同步。本以为问题解决,但后来发现虚拟机的时间偶尔还是会和ESXi主机同步,导致慢几分钟。而且该ESXi主机的NTP SERVER也设置了DC的IP,与DC时间同步,但根本就同步不成功。于是在网上搜索并与VMware工程师联系,得到了以下两个重要的KB:

1.   如何让ESX/ESXi主机与DC时间同步:http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=1035833&sliceId=1&docTypeID=DT_KB_1_1&dialogID=228703032&stateId=0 0 228699835
Configure ESX/ESXi NTP and Likewise Clients
Configure ESX/ESXi to synchronize time with the Windows server Active Directory Domain Controller:
1.   Connect to the ESX/ESXi host or vCenter Server using the vSphere Client.
2.   Select the ESX/ESXi host in the inventory.
3.   Click the Configuration tab.
4.   Under the Software heading, click Time Configuration.
5.   Click Properties.
6.   Ensure that the NTP Client Enabled option is selected.
7.   Click Options.
8.   Click NTP Settings.
9.   Click Add and specify the fully qualified domain name or IP address of the Windows server Domain Controller(s).
10. Click OK.
11. Click OK to save the changes.
Additional configuration must be done from the command line.
1.   Open a console to the ESX or ESXi host. For more information, see Unable to connect to an ESX host using Secure Shell (SSH) (1003807) or Using Tech Support Mode in ESXi 4.1 (1017910).
2.   Open the file /etc/ntp.conf in a text editor. For more information, see Editing configuration files in VMware ESX (1017022).
3.   Add the tos maxdist command on its own line:

tos maxdist 30
4.   Save the configuration file.
5.   Make the file /etc/likewise/lsassd.conf writable using the command:

chmod +w /etc/likewise/lsassd.conf
6.   Open the file /etc/likewise/lsassd.conf in a text editor. For more information, see Editing configuration files in VMware ESX (1017022).
7.   Locate the sync-system-time option, uncomment it, and set the value to no:

sync-system-time = no
8.   Save the configuration file.
9.   On ESXi, save the configuration changes to the boot bank so they persist across reboots using the command:

/sbin/auto-backup.sh
10. Restart the ntpd and lsassd service for the configuration change to take effect using the commands:

service lsassd restart
service ntpd restart

Note: To restart the ntpd and lsassd services on an ESXi host use the below commands:

./etc/init.d/lsassd restart
./etc/init.d/ntpd restart
 
2.如何完全禁止虚拟机与ESX/ESXi主机的时间同步
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1189
Select the virtual machine in the VMware Infrastructure Client inventory. On the Summary tab, click Edit Settings, then click the Options tab and select General (under Advanced). Click Configuration Parameters, then click Add Row and add this information:
tools.syncTime = "0"
time.synchronize.continue = "0"
time.synchronize.restore = "0"
time.synchronize.resume.disk = "0"
time.synchronize.shrink = "0"
time.synchronize.tools.startup = "0"
time.synchronize.resume.host = "0"
 
如果单单在VMware tools 中禁止虚拟机与ESX/ESXi主机时间同步,仅会禁止周期性的时间同步,但当以下情况发生时,虚拟机还是会与ESX/ESXi主机时间同步:
1)当暂停VMs后,下次恢复VMs时,它会与主机时间同步。
2)当使用vMotion迁移主机,制作快照,恢复快照,收缩虚拟硬碟,或者重启VMware tools Service,或重启VMs后,时间会重新和主机同步
 
个人建议:使用第一个KB让ESX/ESXi主机DC时间同步,不要使用第二个KB。然后在虚拟机的VMware tools中禁止虚拟机与ESX/ESXi主机同步就可以了。因为要考虑到,如果有虚拟长时间关机或者脱域,当虚拟机开机后,就不一定能成功与DC时间同步了,但此时它可以同步ESX/ESXi主机的时间。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章