我在Windows 8 Hyper-V上运行的虚拟Debian 8机器上遇到了date停滞的问题。 我没有做很多安装后的configuration,这是一个故意安装而不是花哨的东西 – 我只是使用该框作为独立的POSIX环境,通过SSHloginPuTTY。
date似乎“冻结”,当主持人睡觉,并在一天左右后翻转主机笔记本电脑上的盖子后,将其唤醒。 从Windows上的PuTTy到VM的SSH会话始终保持不变。 我不想用Linux的Hyper-V特定的时间同步服务,我很满意使用NTP。 NTP已经安装了apt-get install ntp ,最初我用systemctl status ntp获得了以下内容:
● ntp.service - LSB: Start NTP daemon Loaded: loaded (/etc/init.d/ntp) Active: active (running) since Mon 2017-08-14 23:16:55 CEST; 20h ago Process: 1167 ExecStop=/etc/init.d/ntp stop (code=exited, status=0/SUCCESS) Process: 1175 ExecStart=/etc/init.d/ntp start (code=exited, status=0/SUCCESS) CGroup: /system.slice/ntp.service └─1184 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 108:115
今天,从昨天醒来后,笔记本电脑再次观察“冻结”的date,同样的命令告诉我服务已经退出:
● ntp.service - LSB: Start NTP daemon Loaded: loaded (/etc/init.d/ntp) Active: active (exited) since Mon 2017-08-14 21:28:57 CEST; 1h 43min ago Process: 450 ExecStart=/etc/init.d/ntp start (code=exited, status=0/SUCCESS)
为什么服务似乎自行退出? 显然只要主机从睡眠/冬眠解冻就会退出。 而且,所有事情的0/SUCCESS ,让我相信它的行为是如此的devise,没有遇到错误?
一旦我systemctl restart ntp过程回来了计划的进程之间和date是同步的。 做systemctl start ntp没有相同的效果(可能是因为它已经“加载”/“活跃”)。
这是怎么回事? 是不是NTP应该一直在运行,当它漂移时需要定期同步时钟? 内核中的某些与Hyper-V相关的模块是否考虑了微软build议不要将NTP与虚拟机一起使用,或者networking堆栈导致NTP保留? 即使它是UDP,甚至到VM的SSH仍然存在,那为什么会这样呢?
/etc/ntp.conf,从来没有编辑它自己:
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(6) for help driftfile /var/lib/ntp/ntp.drift # 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 # You do need to talk to an NTP server or two (or three). #server ntp.your-provider.example # pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will # pick a different set every time it starts up. Please consider joining the # pool: <http://www.pool.ntp.org/join.html> server 0.debian.pool.ntp.org iburst server 1.debian.pool.ntp.org iburst server 2.debian.pool.ntp.org iburst server 3.debian.pool.ntp.org iburst # 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
默认情况下,如果系统时间离计算时间太远, ntpd将会退出。 (我不知道它将使用什么退出代码。)您可以添加configuration指令tinker panic 0以防止它退出。