我在一些(硬件)服务器中看到了一个奇怪的系统时间变化行为:在/var/logs/syslog
中,每条日志消息之前的日期时间有时会更改为随机的,并在下一条消息中恢复正常,如下所示:
Feb 22 2018 09:09:30 ...
Feb 22 2018 09:09:32 ...
Jan 13 2610 15:37:42 ...
Feb 22 2018 09:09:33 ...
Feb 22 2018 09:09:34 ...
就像在这个例子中一样,日期的突然变化可能会在几百年后发生。
我可以确认,具有奇怪时间戳的日志消息并不来自任何特定的进程--它可以随机地发生在每个进程中。
两个异常时间变化之间的持续时间介于几分钟到几个小时之间(不过,我怀疑异常时间更改可能会发生得更频繁,但其中许多变化不会在syslog中显示,因为它不是每秒写入日志)。
而且,由于它发生在多台服务器上,所以我认为它不是硬件问题。
更多关于服务器的信息:它们是一个openstack安装,有一个控制器和几个计算节点。每个服务器都在运行ntp服务。控制器被配置为从其自己的硬件时钟中抽出时间,计算节点服务器从控制器同步时间。注意,每个服务器都有自己的异常时间变化--看起来“错误的时间”不是通过ntp从控制器同步的。
我怀疑计算节点上的来宾系统(虚拟机)可能会影响它们的主机系统时间。但是这不能解释为什么控制器在没有运行任何虚拟机的情况下有同样的问题。
我需要一种方法来检测:是谁改变了系统时间以及它是如何发生的?
发布于 2018-11-06 01:13:29
相关的方面是内核版本,以及从启动过程的早期开始的这些行:
kernel: Fast TSC calibration using PIT
...
kernel: Calibrating delay loop (skipped), value calculated using timer frequency..
...
kernel: Switching to clocksource tsc
YMMV和你可能不使用TSC或PIT
AFAIK --这是一个错误,它是由至少一个CPU的时钟不同步引起的,在您的情况下可能运行得太快了。
通过运行以下命令可以很容易地确认:
for cpu in {0..8} ; do taskset -c $cpu date ; done
它将针对每个cpu运行date
(假设您有多达8个核心/线程)。如果我的猜测是正确的,那么您的CPU之一将始终有错误的时间。
如果是这种情况,那么您应该首先尝试升级内核,如果不起作用,就使用clocksource引导参数(假设它是x86-64
):
clocksource= Override the default clocksource
Format: <string>
Override the default clocksource and use the clocksource
with the name specified.
Some clocksource names to choose from, depending on
the platform:
[all] jiffies (this is the base, fallback clocksource)
[ACPI] acpi_pm
...
[X86-64] hpet,tsc
还请参见该文件的输出:
cat /sys/devices/system/clocksource/clocksource*/available_clocksource
发布于 2018-11-21 11:07:56
简而言之,我正在使用的rsyslog版本中有一个bug,它会将它收到的syslog消息延迟任意时间。窃听器报告在这里。和升级rsyslog解决了这个问题。这不是克伦的错。
发布于 2018-11-16 21:42:20
看起来,控制器服务器上的硬件时钟不是一个稳定的时间信息资源。您应该将控制器配置为将其类型与更可靠的原子钟同步。
这是您可以用来更新硬件时钟的命令:hwclock -s
另请参阅:
-s, --hctosys
Set the System Time from the Hardware Clock.
Also set the kernel's timezone value to the local timezone as indicated by the TZ environment variable and/or /usr/share/zoneinfo, as tzset(3) would interpret them. The obsolete tz_dsttime field of the kernel's time‐
zone value is set to DST_NONE. (For details on what this field used to mean, see settimeofday(2).)
This is a good option to use in one of the system startup scripts.
-w, --systohc
Set the Hardware Clock to the current System Time.
https://unix.stackexchange.com/questions/460983
复制相似问题