运行CentOS版本5.8
我在一个服务器上出现了时间漂移问题,我修复了这个问题--它没有同步hwclock,这样在重新引导ntp时,ntp就会超过1000秒,永远不会同步时间。
在研究这个问题时,我注意到ntpd经常同步到Local(0)。
“答案”--除非您希望在连接到其他时间服务器失败时将此服务器用作本地时间服务器,否则不需要使用不受约束的本地时钟。
记录来自ntpd的消息:
Jul 20 03:47:49 localhost ntpd[5441]: synchronized to 110.14.8.1, stratum 3
Jul 20 04:21:06 localhost ntpd[5441]: synchronized to LOCAL(0), stratum 10
Jul 20 04:38:09 localhost ntpd[5441]: synchronized to 110.14.8.1, stratum 3
Jul 20 04:55:26 localhost ntpd[5441]: synchronized to LOCAL(0), stratum 10ntpd.conf:
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 10.4.58.21
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10我们将禁用本地同步,但仍然好奇为什么本地同步会发生。我们在同一子网上放置了一个临时时间服务器,ntpd仍然同步到本地时间。(*可能的答案: ntpdc -c sysinfo表明ntp服务器的起始层为11,这比我们告诉ntpd用于本地的10更糟糕。是时候看ntpd *的源代码了
Jul 24 17:11:32 localhost ntpdate[5432]: step time server 227.220.222.220 offset 1629.764734 sec
Jul 24 17:11:32 localhost ntpd[5434]: ntpd 4.2.2p1@1.1570-o Fri Nov 18 13:21:21 UTC 2011 (1)
Jul 24 17:11:32 localhost ntpd[5435]: precision = 1.000 usec
Jul 24 17:11:32 localhost ntpd[5435]: Listening on interface wildcard, 0.0.0.0#123 Disabled
Jul 24 17:11:32 localhost ntpd[5435]: Listening on interface wildcard, ::#123 Disabled
Jul 24 17:11:32 localhost ntpd[5435]: Listening on interface eth0 Enabled
Jul 24 17:11:32 localhost ntpd[5435]: Listening on interface lo, ::1#123 Enabled
Jul 24 17:11:32 localhost ntpd[5435]: Listening on interface lo, 127.0.0.1#123 Enabled
Jul 24 17:11:32 localhost ntpd[5435]: Listening on interface eth0, 192.12.140.55#123 Enabled
Jul 24 17:11:32 localhost ntpd[5435]: kernel time sync status 0040
Jul 24 17:11:32 localhost ntpd[5435]: frequency initialized 0.000 PPM from /var/lib/ntp/drift
Jul 24 17:14:48 localhost ntpd[5435]: synchronized to LOCAL(0), stratum 10
Jul 24 17:16:55 localhost ntpd[5435]: synchronized to 192.12.140.200, stratum 3
Jul 24 20:11:06 localhost ntpd[5435]: synchronized to LOCAL(0), stratum 10
Jul 24 20:20:50 localhost ntpd[5435]: synchronized to 192.12.140.200, stratum 3发布于 2012-07-21 14:14:53
ntpd不负责同步本地硬件时钟。通常,有一个程序提供这样做。在Ubuntu上,程序是hwclock。它在启动时用于设置系统日期,在关闭时用于更新它。
我通常只将硬件时钟配置为本地NTP时间服务器上的时间源。如果我在客户端上配置它,我会将它们设置在一个更高的层次上,这样如果可以访问时间服务器,时间服务器就会保持时间权威。
如果使用ntpd与本地时钟同步,请将硬件时钟设置为UTC,并将系统配置为在启动时期望从时钟中获得UTC。不幸的是,如果您对Windows进行双引导,这将不能很好地工作。在这种情况下,不要使用本地时钟作为时间源。
从您的输出中可以看出,您有一个间歇性的外部时间源,这将导致您从硬件时钟来回翻转。即使可以到达,外部时间源也可能丢失了自己的同步,而不被视为时间源。如果您有固定的网络连接,则再添加几个时间源。如果您有间歇性的网络连接,可以修复硬件时钟设置,或者删除硬件时钟作为源。
您的硬件时钟在启动时关闭了1000秒以上,这一事实表明了两个可能的问题之一:
通过将-g选项添加到ntpd命令中,您可以在启动时解决同步问题。
发布于 2012-07-20 20:33:01
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.如果您无法访问任何官方服务器(更多),这意味着作为后备时间源。如果启用了漂移文件,这甚至可能会使您的时间保持同步,因为漂移文件应该包含针对本地时钟的实时校正值。
发布于 2012-07-20 20:17:38
同步到本地时间源,如果没有实际存在,是一个伟大的方式,让你的时钟失控。你发现了困难的方法(就像我不久前所做的那样)。这是为了你有一个GPS,原子钟,或一些相关的情况下,物理上合并到机器。如果您没有这样的硬件,请禁用它。
https://unix.stackexchange.com/questions/43622
复制相似问题