System Time becomes incorrect on reboot of VMs

ぐ巨炮叔叔 提交于 2020-05-15 08:24:25

问题


Ever since virtualizing several physical servers into GCP, I have had an issue where anytime the servers(s) are rebooted the time is changed to be several hours ahead (I think it's 4 hours, but may be 6 hours). My local office is located in CST time zone and that is what we want the server to display. In GCP the virtual servers are in the us-central1a zone. On the virtual server, run the tzutil /g command it shows that the server is set to "central standard time". It also shows Central timezone if I click the clock on the toolbar then choosing "change date and time settings"

After the server has been rebooted (and reports wrong time) I can correct the time by clicking the "update now" options (found on toolbar clock, "change date and time settings", internet time tab, change settings" "update now" (this points to time server time.nist.gov).

This issue only began occurring after migrating into GCP so I believe it to be a Compute Engine issue and not an OS issue.

any thoughts on why this might be happening? I have this on occurring on all 4 windows servers that were migrated into Google Cloud. three are win2008r2, and one is Win2012r2

I appreciate any help that can be given to get this resolved, as I can't even reboot without connecting to the server afterwards and checking/fixing the time, I do have set a startup script to delay and then sync time after rebooting, but it has not worked 100% of the time, so this is more of a band-aid than a fix.


回答1:


I do have set a startup script to delay and then sync time after rebooting, but it has not worked 100% of the time, so this is more of a band-aid

Getting this script working is probably the solution, here. For what it's worth, you'd need to do the same thing on both Azure and AWS as well, since they also set Windows timezones to UTC by default using the same mechanism.

  • See AWS docs on the Specialize Phase
  • See this Stackoverflow question for a similar question about Windows on Azure

Normally all servers run on UTC time, its clients (applications, browsers, etc) set their timezones according to where they are, and its up to them to translate UTC time to whichever locale they are in. (Put another way, you wouldn't want a server with a million client connections to have to keep track of each client's timezone in order to work properly). In your case, the bottom line is that requiring a custom timezone on the server will also require a custom server configuration, and the behavior you're seeing is by design. That's why your best bet is to understand why the startup script isn't working like you expect it to.

For reference, these docs may be helpful:

  • Google Compute Engine: Providing a startup script for Windows instances
  • Google Compute Engine: Creating a Windows Image



回答2:


If you looked at the VM instance logs in the GCP Console you'd see that VM BIOS reports time in UTC

2019/10/3 14:9:44 Begin firmware boot time

After a while BIOS hands over to the bootloader

2019/10/3 14:9:45 End firmware boot time
Booting from Hard Disk 0...

The OS boots up. Behind the scene the OS time service recognizes the system timezone, then sets up and synchronizes time with the time source. From that time forward running programs and services report events based on the local system time:

...
2019/10/03 09:10:05 GCEWindowsAgent: GCE Agent Started (version 4.6.0@1)

In the Windows Event Log you should see entries made by the Time-Service:

Log Name: System
Source: Time-Service
Level: Information

The time provider NtpClient is currently receiving valid time data from metadata.google.internal,0x1 (ntp.m|0x1|0.0.0.0:123->169.254.169.254:123).
The time service is now synchronizing the system time with the time source metadata.google.internal,0x1 (ntp.m|0x1|0.0.0.0:123->169.254.169.254:123).

In the command prompt you can ensure that the time configuration and state are correct:

C:\Users\user>systeminfo | find /i "Time"
System Boot Time:          10/3/2019, 9:09:49 AM
Time Zone:                 (UTC-06:00) Central Time (US & Canada)

Hence you don't need synchronizing time neither manually or with with a startup script. The time service will do it for you: to synchronize the system time right after the boot and to keep it in sync afterwards. All you need is to set correct Time zone and the Internet time server for Windows, and then make sure the time server is reachable via the network.



来源:https://stackoverflow.com/questions/58192450/system-time-becomes-incorrect-on-reboot-of-vms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!