这次笔者需要面对的环境对时间的同步有比较高的要求, 而虚拟化的环境中时间是比较容易出问题的, 您可以参考上一篇博文为什么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的时间

一台ESXi的时间

懂行的你一定会说, 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服务.

 

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

 

另外, 文章ntpd - Network Time Protocol (NTP) daemon有如下的介绍:

Most operating systems and hardware of today incorporate a time-of-year (TOY) chip to maintain the time during periods when the power is off. When the machine is booted, the chip is used to initialize the operating system time. After the machine has synchronized to a NTP server, the operating system corrects the chip from time to time. In case there is no TOY chip or for some reason its time is more than 1000s from the server time, ntpd assumes something must be terribly wrong and the only reliable action is for the operator to intervene and set the clock by hand. This causes ntpd to exit with a panic message to the system log. The -g option overrides this check and the clock will be set to the server time regardless of the chip time. However, and to protect against broken hardware, such as when the CMOS battery fails or the clock counter becomes defective, once the clock has been set, an error greater than 1000s will causentpd to exit anyway.

注意粗体的部分, 说如果NTP client的时间与server的时间相差超过1000秒, 那么NTPD就会假设发生了严重的错误, 从而只能手动进行时间调整. 笔者在测试时, 时间差超过了1000秒, 也成功同步了.

 

命令列表

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

cp /etc/ntp.conf /etc/ntp.conf.bak

vi /etc/ntp.conf

“tos maxdist 30”

cp /etc/likewise/lsassd.conf /etc/likewise/lsassd.conf.bak

chmod +w /etc/likewise/lsassd.conf

vi /etc/likewise/lsassd.conf

“sync-system-time = yes”

/sbin/auto-backup.sh

./etc/init.d/lsassd restart

./etc/init.d/ntpd restart

 

参考资料

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

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/

Guide to configure NTP on ESX servers (1003063)

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

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

Windows Time Service Tools and Settings

http://technet.microsoft.com/en-us/library/cc773263(v=ws.10).aspx

VMware ESXi 5.5无法与Windows 2012 NTP Server同步时间的更多相关文章

  1. 创建一个Windows的NTP Server

    搭建一个VMware vRealize Suite的时候遇见了不少时间同步的问题, 实验室里网络与外界隔绝, 不能使用公网的NTP服务器, 所以使用文中的方法自己搭建了一个. 蛮好用的. Creati ...

  2. 体验vSphere 6之1-安装VMware ESXi 6 RC版(转载)

    体验vSphere 6之1-安装VMware ESXi 6 RC版 在2015年,各个公司都会发布一系列新的产品,例如Microsoft会发布Windows 10,VMware会发布vSphere 6 ...

  3. Vmware ESXI 安装Windows

    Vmware ESXI 安装Windows >ESXi专为运行虚拟机.最大限度降低配置要求和简化部署而设计.只需几分钟时间,客户便可完成从安装到运行虚拟机的全过程,特别是在下载并安装预配置虚拟设 ...

  4. VMware ESXi 不支持NTFS格式的USB外接硬盘

    本来想搞直通USB外接大容量硬盘(希捷Seagate Backup+ Hub WH 8T),实现在同一部ESXi下,直接将NAS的数据转移到外接硬盘.结果发现虚拟机下的win server系统识别不了 ...

  5. VMware ESXi 7.0 U2 SLIC & Unlocker Intel NUC 专用镜像

    构建 Nano Datacenter 的两大平台 在测试环境或者家庭实验室(Home lab)中使用 VMware vSphere 作为虚拟化平台非常普遍,笔者更倾向使用 Nano Datacente ...

  6. VMware ESXi 7.0 U2 SLIC & Unlocker Intel NUC 专用镜像 202109 更新

    2021.08.31 更新:集成 "vmkusb-nic-fling" 和 "nvme-community",现在只有一个镜像. 2021.06.16 更新:集 ...

  7. VMware ESXi 7.0 U2 SLIC 2.6 & Unlocker 集成 Intel NUC 网卡、USB 网卡和 NVMe 驱动

    ESXi 7 U2 标准版镜像集成 NUC 网卡.USB 网卡 和 NVMe 驱动. 请访问原文链接:https://sysin.org/blog/vmware-esxi-7-u2-nuc-usb-n ...

  8. VMware ESXi 8.0 SLIC 2.6 & macOS Unlocker (Oct 2022 GA)

    ESXi 8.0.0 GA (General Availability) 请访问原文 VMware ESXi 8.0 SLIC 2.6 & macOS Unlocker (Oct 2022 G ...

  9. RHEL 6.5 PXE 安装调试 VMWARE ESXi 5.1 安装

    测试环境:win10/vmware workstation 12 pro 操作系统:RHEL 6.5(PXE服务器) [2016.11.30] [遗留问题] 1.ks.cfg通过本地文件方式加载不成功 ...

随机推荐

  1. Linux内核编译安装

    1. .config 复制一份当前系统编译时的配置,在/usr/src目录下 $ ls /usr/src/ linux-headers-4.10.0-35 linux-headers-4.8.0-36 ...

  2. React学习笔记2017-12-31

    课程:https://coding.imooc.com/class/chapter/150.html 第一章:介绍 第二章:知识储备 React开发环境 1.安装Nodejs 2.安装Visual S ...

  3. Python 函数系列 - Str对path的处理

    由此可见,“\”是转义字符,它能够将第2个“\”从转义字符转回普通字符,从而“\n”就不再起到换行符的作用. 这样操作虽然简单,但是遇到下方这个路径,看起来就会有些麻烦! path = 'D:\new ...

  4. Java 打开文件夹

    package com.swing.demo; import java.io.File; import java.io.IOException; public class OpenDirTest { ...

  5. HTML中的ul, ol,li , dl,dt, dd标签

    ul: unordered lists ol: ordered lists li: Lists ol 有序列表. <ol><li>……</li><li> ...

  6. 光线求交-面、三角形、球 (Ray intersection)

    光线求交 光线定义:position \(a(t)\) = \(o\) + \(t\vec{d}\); 球定义: center p, radius r; 平面定义:normal \(\vec{n}\) ...

  7. hdu 1690 Bus System (有点恶心)

    Problem Description Because of the huge population of China, public transportation is very important ...

  8. 常用排序算法的Python实现

    冒泡排序 算法思想: 对于一组需要排序的数据,对于相邻的两个数进行比较,使较大(或者较小)的数一直向后推,经过多层排序之后,使整个序列是有序的. 算法实现: def bubble_sort(L): l ...

  9. 01-学前入门概念:.net与c#

    .Net是由(.Net 平台和.Net FrameWork框架)这两部分组成. .Net FrameWork是由(CLR公共语言运行时和.Net 类库组成). .Net FrameWork框架是.Ne ...

  10. codeforces 220 C. Game on Tree

    题目链接 codeforces 220 C. Game on Tree 题解 对于 1节点一定要选的 发现对于每个节点,被覆盖切选中其节点的概率为祖先个数分之一,也就是深度分之一 代码 #includ ...