这是我的场景:我在工作站上运行多个VM来模拟生产环境.在一天结束时,我在下午6点睡觉我的工作站(我的VM在后台运行).当我第二天早上8点回到办公室并唤醒工作站时,我的所有虚拟机都在下午6点.
厌倦了重置NTP或只是想记住强制更新,我将以下内容放在5分钟的cron中
服务ntp stop&& ntpd -gq&&服务ntp开始
这是我的/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
有没有更好的方法来实现这一目标?
如果您使用的是VMware Workstation(或VMware vSphere),则有
specific ways to handle timekeeping on your (Linux) virtual machines.但是,这对于您的睡眠情况来说还不够.仅限来宾的NTP在这里没有帮助.
您绝对需要在来宾虚拟机上安装VMware来宾工具,并确保在主机上运行NTP.这将解决睡眠问题和客人被暂停时发生的漂移.
编辑:
哦,这是Ubuntu …我发现很多Ubuntu用户都没有安装本机VMware工具套件. Here are the steps(以及一个视频)来实现这一目标.