Tag Archives: ntp

How to setup NTP services by PowerCLI

NTP service is very important for troubleshooting, vmkernel log timestamp is incorrect if your NTP service is not running and ESXi system time is wrong. It can also impact to VM system time even you disable time synchronization on VMware Tools since VM still need to sync time with ESXi after awake from suspended status, finish vMotion, or revert from snapshot.

I know it’s simple to configure NTP services on single how, what if you want to configure NTP service on massed hosts?

Basically we have 3 steps to make sure NTP service working properly:

  • Configure NTP server IP address.
  • Bring up NTP service.
  • Set services startup along with ESXi system.

Let’s try PowerCLI:

Get-VMHOST -Location Cluster Name | Add-VMHostNtpServer -NtpServer “NTP server address

Get-VMHOST -Location Cluster Name | Get-VMHostService| Where-Object {$_.key -eq “ntpd”} | Start-VMHostService

Get-VMHOST -Location Cluster Name | Get-VMHostService| Where-Object {$_.key -eq “ntpd”} | Set-VMHostService –Policy On

Advertisements

Time synchronization on virtual machine

Guest OS of virtual machine can synchronize time by several way, such as NTP, VMware Tools, Windows Time Service, CMOS…etc.

VMware Tools synchronize time with ESXi host when  you enable periodic time synchronization. VMware Tools time synchronization function is disabled by default, but that’s doesn’t means time synch never happens between guest OS and host. It still happens after certain operations:

  • When the VMware Tools daemon is started.
  • When resuming a VM from suspended status.
  • After reverting from a snapshot.
  • After shrinking a disk.

It can causes some problem if guest OS have different time with host, it can lead to SAP application failed due to SAP database timestamp different with guest OS.

You can completely disable the time synchronization by following step:

  • Power off the VM.
  • Add following lines to .vmx file.
    tools.syncTime = “FALSE”
    time.synchronize.continue = “FALSE”
    time.synchronize.restore = “FALSE”
    time.synchronize.resume.disk = “FALSE”
    time.synchronize.shrink = “FALSE”
    time.synchronize.tools.startup = “FALSE”
  • Save and close the file.
  • Power on the VM.

You can also refer VMware official document.

Here is also a useful KB article for timekeeping best practices for Linux VM.