如何解决虚拟机时钟漂移问题?

发布于 2024-07-05 01:40:31 字数 120 浏览 6 评论 0原文

我的虚拟机的时钟漂移非常明显。 有关于处理这个问题的文档,但似乎没有什么效果很好。

任何人都有任何建议,对他们来说效果很好的东西,...

据说通过 ntp 定期更新不是一个好的解决方案。

My Virtual Machine's clock drifts pretty significantly. There's documentation out there about dealing with this, but nothing seems to be working very well.

Anyone have any suggestions, things that worked well for them, ...

Supposedly updating regularly via ntp is not a good solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

浅浅 2024-07-12 01:40:31

您可以使用 cmd 来

net time \\computer_name /set

远程设置时钟(或者例如在脚本中)

You can use the cmd and

net time \\computer_name /set

to set the clock remotly (or in a script for example)

寄人书 2024-07-12 01:40:31

这是一个老问题,但最近影响了我们。 我发现我们运行 vmware 工具的任何虚拟机都受到该问题的影响。

最近,我们开始使用 open-vm-tools,但在这些虚拟机上未设置该选项。 由于 Vmware 完全支持和推荐 open-vm-tools,因此我建议在 vmware 工具上使用它:http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2073803

如果 open-vm -tools 位于您使用的存储库中,通过 yum install 或 apt-get install 等方式安装也很简单。

This is an old issue but one that was affecting us recently. What I found was that any of our vm's that were running vmware tools were affected by the issue.

More recently we had started using open-vm-tools and on those vm's the option was not set. Since open-vm-tools is fully supported and recommended by Vmware I would suggest using it over vmware tools: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2073803

If open-vm-tools is in a repository that you use it is also simple to install via yum install or apt-get install etc.

蓝海 2024-07-12 01:40:31

如果您还没有安装 NTP,请安装它。

ntpdate将正确设置时钟,然后ntpd可以保持时钟准确。

NTP 池项目 提供了大量可供选择的 NTP 服务器。

编辑刚刚注意到您说您认为 NTP 不是一个好的解决方案 - 为什么? 如果您担心时钟变化的影响,NTP 是理想的选择,因为 ntpd 不会向前或向后跳跃时钟,而是通过稍微加速/减速来“旋转”时钟,直到它回到与时钟一致的位置。正确的时间。

Install NTP if you don't already have it.

ntpdate will set the clock correctly, then ntpd can keep the clock accurate.

The NTP pool project provides a large pool of NTP servers to pick from.

Edit just noticed you said you think NTP is not a good solution - why? If you're worried about the effect of the clock changing, NTP is the ideal, as ntpd does not jump the clock forwards or backwards, instead it "slews" the clock by speeding it up/down slightly until it's back in line with the correct time.

对你而言 2024-07-12 01:40:31

我遇到了同样的问题,并通过

  1. 安装 vmware-guestd
  2. 向内核发送选项 Clocksource=acpi_pm 来
  3. 解决它,每小时以 root 身份运行 hwclock -s 。

I had the same problem and solved it by

  1. installing vmware-guestd
  2. sending the kernel an option clocksource=acpi_pm
  3. running hwclock -s hourly as root.
云雾 2024-07-12 01:40:31

这个问题的最佳解决方案是(如果本地连接)
安装本地 NTP 服务器并将“service ntp restart”置于无限循环中,睡眠时间约为 30 秒。 通过在“/etc/init.d/rc.local”文件中编写代码。 重新启动系统,时间将与服务器计算机同步。

The best solution to this problem is (if locally connected)
Install Local NTP server and put "service ntp restart" in an infinite loop with sleep time 30 seconds approx. by writing a code in "/etc/init.d/rc.local" file. Reboot system and time will be synchronized with the server computer.

郁金香雨 2024-07-12 01:40:31

安装虚拟机附加功能(工具)不会同步来宾操作系统和主机操作系统之间的时钟吗?

Doesn't installing the virtual machine additions (tools) synchronize the clock between the guest and host OS?

明月夜 2024-07-12 01:40:31

据说通过ntp定期更新
这不是一个好的解决方案

,但这就是我推荐的解决方案。 为什么它在您所在的位置不被认为是好的?

Supposedly updating regularly via ntp
is not a good solution

That's the solution I would recommend, though. Why is it not considered good at your location?

亣腦蒛氧 2024-07-12 01:40:31

没有明确的答案,因为存在多种方法,每种方法都有其优点和缺点。 选择哪一种取决于您的任务、服务器负载、操作系统等。

请阅读 vmware_timekeeping.pdf< /a> 彻底了解问题。

适用于 Linux 的快速秘诀可在单独的知识库文章中找到

There is no definitive answer because several methods exist, each having its pros and cons. What one to chose depends on your tasks, server load, operating system, etc.

Read vmware_timekeeping.pdf for thorough understanding of the issue.

Quick recipes for Linux could be found in a separate KB article

森末i 2024-07-12 01:40:31

只是添加一些关于为什么 NTPD 不是一个好的解决方案的数据。 NTPD 是一个试图补偿本地时钟漂移的守护进程; 如果“内部时钟”在一天中偏离了 X 秒,那么 NTPD 不会像“ntpdate”中那样像强制命令那样向前/向后跳跃,而是尝试向时钟添加/删除一些周期,以便及时正常地进行在 15 分钟内,时钟运行足够准确,并且补偿克服了服务器一天中增加/损失的 X 秒数。 这样做的优点是您不会看到一天中的任何时间重复,这对于事务系统来说是必须的。

但为了能够做到这一点,NTPD 要求本地时钟做得相当好,这通常意味着本地时钟每天的偏差不会超过 42 秒(或多或少;我不确定确切的时间)数字)。 这通常是虚拟机中的一个问题,因为时钟是由软件控制的,所以如果主机过载太多,您可能会看到客户端的时钟运行得更慢,如果没有,那么时钟也可能运行得太慢快速地。 NTPD 的问题是本地时钟不可靠并且没有持续的时间漂移​​; 它可能或多或少取决于主机系统的过载。

因此,在这种情况下,最好按照建议安装客户端工具,并将客户端时钟与主机时钟(通常称为“挂钟”)同步

Just to add some data about why NTPD is not a good solution. NTPD is a daemon that tries to compensate for the local clock drift; if the "internal clock" drifts away by X number of seconds in a day, then instead of jumping ahead/back like a forced command as in "ntpdate " NTPD tries to add/remove some cycles to the clock so that in time, normally within 15 minutes, the clock runs accurately enough and the compensation overcomes this X numbers of seconds that the servers gains/losses in a day. This has the advantage that you won't see any time in the day repeated, which is a MUST for for transactional systems.

But to be able to do this, NTPD requires that the local clock does a reasonably good job, which normally means that the local clock won't drift apart more than 42 seconds a day (more or less; I am not sure of the exact number). This normally is a problem in Virtual Machines, since the the clock is software controlled, so if the HOST has too much overload, you could see that the CLIENT's clock will run more slowly, and if it doesn't then the clock could run too fast. The problem here for NTPD is that the local clock is not reliable and doesn't have a constant drift in time; it may be more or less depending on the overload of the HOST system.

So in this case it's better to install the client tools as has been suggested, and synchronize the CLIENT clock with the HOST's clock (normally referred as the "wall clock")

独闯女儿国 2024-07-12 01:40:31

vmware 有关于此问题的一个非常好的 PDF 文档

基本上,主人会尽可能杀死传递给客人的蜱虫。
不要运行 NTP 或定时或类似的垃圾。 只需安装 vmware-guestd,然后让主机来消灭你的蜱虫。 如果你仍然失去蜱虫,那么任何其他解决方案也会有重大漂移。

如果可以,请使用具有低频率滴答率的来宾操作系统。 较新版本的 Linux 带有 1000Hz 滴答声,但以前仅为 100Hz。 对于楼主来说,这似乎更容易实现。 通常需要重建内核来更改 HZ 值。

vmware have a really good PDF doc on this problem.

Basically, the host will slew the ticks delivered to your guests as it can.
Don't run NTP or timed or junk like that. Just install vmware-guestd and let the host slew your ticks. If you still lose ticks, then any other solution will have major drift too.

If you can, use a guest OS that has a low frequency tick rate. Newer versions of Linux come with 1000Hz ticks, but it used only to be 100Hz. That seems easier for the host to deliver. A kernel rebuild is usually needed to change the HZ value.

绮烟 2024-07-12 01:40:31
  1. 在听别人讲话之前,请仔细阅读 vmware 文档。 我们正在运行 ESX5。

Linux 来宾的计时最佳实践包括:
参考:http://kb.vmware .com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006427

NTP 建议
注意:VMware 建议您使用 NTP 而不是 VMware Tools 定期时间同步。 NTP 是一个行业标准,可确保您的客人准确掌握时间。 您可能必须打开防火墙 (UDP 123) 以允许 NTP 流量。

这是一个示例 /etc/ntp.conf:

tinker panic 0
restrict 127.0.0.1
restrict default kod nomodify notrap
server 0.vmware.pool.ntp.org
server 1.vmware.pool.ntp.org
server 2.vmware.pool.ntp.org
driftfile /var/lib/ntp/drift

这是一个示例(特定于 RedHat) /etc/ntp/step-tickers:

0.vmware.pool.ntp.org
1.vmware.pool.ntp.org

配置指令tinkerpanic 0 指示 NTP 在发现时间发生较大跳跃时不要放弃。 这对于应对较大的时间漂移​​以及将虚拟机从挂起状态恢复非常重要。

注意:指令tinker panic 0 必须位于ntp.conf 文件的顶部。

同样重要的是不要使用本地时钟作为时间源,通常称为无纪律本地时钟。 当存在大量时间漂移时,NTP 倾向于回退到此,而不是远程服务器。

此类配置的一个示例是:

server 127.127.1.0
fudge 127.127.1.0 stratum 10

注释掉这两行。

更改 NTP 配置后,必须重新启动 NTP 守护程序。 请参阅操作系统供应商的文档。

  1. Read you vmware documentation carefully before you listen to anyone. We are running ESX5.

Timekeeping best practices for Linux guests among other things says:
Ref: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006427

NTP Recommendations
Note: VMware recommends you to use NTP instead of VMware Tools periodic time synchronization. NTP is an industry standard and ensures accurate time keeping in your guest. You may have to open the firewall (UDP 123) to allow NTP traffic.

This is a sample /etc/ntp.conf:

tinker panic 0
restrict 127.0.0.1
restrict default kod nomodify notrap
server 0.vmware.pool.ntp.org
server 1.vmware.pool.ntp.org
server 2.vmware.pool.ntp.org
driftfile /var/lib/ntp/drift

This is a sample (RedHat specific) /etc/ntp/step-tickers:

0.vmware.pool.ntp.org
1.vmware.pool.ntp.org

The configuration directive tinker panic 0 instructs NTP not to give up if it sees a large jump in time. This is important for coping with large time drifts and also resuming virtual machines from their suspended state.

Note: The directive tinker panic 0 must be at the top of the ntp.conf file.

It is also important not to use the local clock as a time source, often referred to as the Undisciplined Local Clock. NTP has a tendency to fall back to this in preference to the remote servers when there is a large amount of time drift.

An example of such a configuration is:

server 127.127.1.0
fudge 127.127.1.0 stratum 10

Comment out both lines.

After making changes to NTP configuration, the NTP daemon must be restarted. Refer to your operating system vendor’s documentation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文