重新启动VM时系统时间变得不正确 [英] System Time becomes incorrect on reboot of VMs

查看:116
本文介绍了重新启动VM时系统时间变得不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从将几台物理服务器虚拟化为GCP以来,我一直遇到一个问题,即每次重新启动服务器时,时间都要提前几个小时(我认为是4个小时,但可能是6个小时).我的本地办公室位于CST时区,这就是我们希望服务器显示的位置.在GCP中,虚拟服务器位于us-central1a区域中.在虚拟服务器上,运行tzutil/g命令,它显示服务器已设置为中央标准时间".如果我单击工具栏上的时钟,然后选择更改日期和时间设置",它还会显示中央时区

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"

服务器重新启动后(并报告错误的时间),我可以通过单击立即更新"选项(位于工具栏时钟,更改日期和时间设置","Internet时间"选项卡,更改设置)来更正时间.立即更新"(指向时间服务器time.nist.gov).

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).

此问题仅在迁移到GCP后才开始发生,因此我认为这是Compute Engine问题,而不是OS问题.

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

为什么会发生这种情况?我已经在迁移到Google Cloud的所有4台Windows服务器上发生了这种情况.三个是win2008r2,一个是Win2012r2

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

我非常感谢您提供的所有帮助来解决此问题,因为我什至在没有连接到服务器并检查/确定时间的情况下甚至无法重启,所以我确实将启动脚本设置为延迟,然后在同步后同步时间.重新启动,但并不能100%地起作用,因此这更多的是创可贴,而不是解决方案.

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.

推荐答案

我确实已将启动脚本设置为延迟,然后在重新启动后同步时间,但是它没有100%的时间起作用,因此这更像是一个创可贴

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

在这里使此脚本正常工作可能是解决方案.对于它的价值,您还需要在Azure和AWS上执行相同的操作,因为它们默认还使用相同的机制将Windows时区设置为UTC.

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

通常所有服务器都以UTC时间运行,其客户端(应用程序,浏览器等)根据它们所在的位置设置时区,并由其将UTC时间转换为它们所在的任何语言环境(换句话说,您不希望一台拥有一百万个客户端连接的服务器必须跟踪每个客户端的时区才能正常工作).在您的情况下,最重要的是,在服务器上要求自定义时区也将需要自定义服务器配置,并且您看到的行为是设计使然.这就是为什么最好的选择是了解启动脚本为何无法如您期望的那样工作.

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

这篇关于重新启动VM时系统时间变得不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆