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主機的時間。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章