VMware ESXi 5.5无法与Windows 2012 NTP Server同步时间

这次笔者需要面对的环境对时间的同步有比较高的要求, 而虚拟化的环境中时间是比较容易出问题的, 您可以参考上一篇博文为什么Domain controller上的time synchronization非常重要? 笔者的环境里, 经过亲自观察, 如果没有时间同步, 虚拟机与标准时间差距在短短的两个小时之内竟然就偏差了近半个小时!

 

按照VMware KB 1003063的说法, ESXi 5.5只要在vCenter的vSphere里配好NTP client就可以了.

Note: For ESX 3.5 and above, NTP can be configured from vSphere Client and no longer requires manual configuration.

然而, 这不是真的.

 

问题描述

===============================================

先介绍笔者的环境:

  • 一台安装了Windows 2012的实体机, 它并不是Domain Controller.
  • 三台ESXi 5.5.
  • 一台安装了vCenter 5.5的Windows 2008 R2虚拟机, 运行在上面的一台ESXi上.

 

按照文档Configuring Windows Time service to use an internal hardware clock的步骤,我将Windows 2012实体机配置成了使用内部硬件时钟的NTP server. 注意, 微软的文章如何在 Windows Server 中配置权威时间服务器是不work的.

按照VMware KB 1003736的步骤, 将三台ESXi 5.5 配置成了与Windows 实体机NTP server 同步时间.

 

结果如图:

NTP Server的时间

VMware ESXi 5.5无法与Windows 2012 NTP Server同步时间

一台ESXi的时间

VMware ESXi 5.5无法与Windows 2012 NTP Server同步时间

懂行的你一定会说, ESXi上只存UTC的时间, 你在vCenter vSphere中看到的时间是convert过了的. 那我就补充一句, 我的vSphere所在的机器的时区已经被设置为与NTP server一样的时区, 而且时间是一样的.

其结论就是, 这个ESXi的NTP有问题, 时间没有同步.

 

问题排查

==============================================

首先, 需要verify我们的NTP server是否是好的.

于是笔者挑选了一台安装在其中一台ESXi上的虚拟机. 注意, 默认情况下只要安装了VMware Tools, 那么即使你没有开启VMware tools的timesync, 虚拟机也会在某些情况下和其宿主去sync时间的, 详见Configure Time Synchronization Between Guest and Host Operating Systems.

这台ESXi的虚拟机的时间是错误的, 因为ESXi的时间是错误的. –_-||

笔者运行了如下的命令, 使这台虚拟机的时间正确了.

net start w32tm

w32tm /config /manualpeerlist:10.110.69.124 /syncfromflags:manual /reliable:yes /update

w32tm /resync /rediscover

由此, 我们证明了NTP server是正常工作的. 笔者把NTP Server的时间设置的与标准时间相差了几分钟, 所以, 可以避免混淆.

 

下一步, 笔者在vSphere里尝试了界面能操作的所有相关东西, 都没能让NTP client正常工作.

笔者按照文章Troubleshooting NTP on ESX and ESXi 4.x / 5.x (1005092)所讲的去排查, 没有结果. 直到, 笔者找到这篇文章.

详细步骤不介绍了, 大家可以自己去看, 我只简单说一下:

1. 在/etc/ntp.conf的最后一行添加一行tos maxdist 30.

2. 修改/etc/likewise/lsassd.conf文件, 取消掉#sync-system-time的注释, 显式地设置sync-system-time = yes

3. 重启lsassd服务和ntpd服务.

 

困扰了笔者好几天的问题终于解决了!

 

参考资料

==============================

Configuring Windows Time service to use an internal hardware clock

http://www.denningelectronics.com/wp-content/uploads/2010/04/TimeService.pdf

VMware ESXi 5.1 will not sync time with Windows 2008 R2 NTP Domain Controller

http://www.virtxpert.com/vmware-esxi-5-1-will-not-sync-time-with-windows-2008-r2-ntp-domain-controller/

Configuring the Windows Time Service

http://blogs.msmvps.com/acefekay/2014/04/26/configuring-the-windows-time-service/

Verifying time synchronization across an ESX/ESXi host environment(1003736)

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

Troubleshooting NTP on ESX and ESXi 4.x / 5.x (1005092)

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

W32tm

http://technet.microsoft.com/en-us/library/w32tm.aspx

VMware ESXi 5.5无法与Windows 2012 NTP Server同步时间,布布扣,bubuko.com

VMware ESXi 5.5无法与Windows 2012 NTP Server同步时间

上一篇:linux 运维有趣的实用工具


下一篇:Why we don’t recommend using List in public APIs