允许 NTP 自动大量更新吗?

允许 NTP 自动大量更新吗?

以下是我的场景:我在工作站上运行多个虚拟机来模拟生产环境。一天结束时,我在下午 6 点让工作站进入睡眠状态(虚拟机在后台运行)。第二天早上 8 点我回到办公室并唤醒工作站时,我的所有虚拟机都在下午 6 点。

厌倦了重置 NTP 或只是记得强制更新,我将以下内容放入 5 分钟的 cron 中

service ntp stop && ntpd -gq && service ntp start

这是我的/etc/ntp.conf

tinker panic 0

driftfile /var/lib/ntp/ntp.drift

logfile /var/log/ntpd.log

# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org

# Use Ubuntu's ntp server as a fallback.
server ntp.ubuntu.com

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
# 
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust


# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient

有没有更好的方法来实现这一点?

答案1

如果您使用的是 VMware Workstation(或 VMware vSphere),在 (Linux) 虚拟机上处理计时的具体方法。但是,这对于您的睡眠情况来说还不够。仅来宾内的 NTP 在这里没有帮助。

你绝对需要安装 VMware 客户机工具在客户虚拟机上并确保 NTP 在主机上运行。这将修复休眠问题以及客户机挂起时发生的漂移。

编辑:

哦,是 Ubuntu...我发现很多 Ubuntu 用户没有安装原生的 VMware 工具套件。步骤如下(和视频)来实现这一点。

答案2

您的 ntp.conf 应该可以正常工作!我发现有时 ntpd 需要很长时间才能纠正相当大的时间差异。(我见过实际纠正需要 12 个小时以上)。

您应该发现,如果您将它放置一夜(没有使用 cron 作业),那么它最终会自行纠正。

答案3

使用iburst也有助于更快地设置时钟,但这仅在服务启动时有效。

大多数应用程序可能希望指定爆发选项与服务器命令一起使用。使用此选项,可以交换大量消息以整理数据并在大约十秒内设置时钟。

您需要想办法在 APCI 恢复时重新启动该服务。(你可以试一下这个。)

相关内容