巨大时差上的时间同步

lem*_*des 4 ntp centos7 chrony

您好,目前我有一个本地 ntp 服务器(chrony)和一个 ntp 客户端(chrony),它们都在工作,但是当我尝试将 ntp 服务器时间更改为从当前时间减去 6 年时。ntp 客户端无法与其同步,它只会在 syslog 上说:

Jan 9 17:29:11 localhost chronyd[9192]: 系统时钟错误 6780812.328260 秒,调整开始

ntp 客户端 (chrony) /etc/chrony.conf 是默认配置,除了服务器指向我的本地 NTP 服务器 (chrony)。这是我的配置

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server local.ntp.server iburst

# Ignore stratum in source selection.
stratumweight 0

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Enable kernel RTC synchronization.
rtcsync

# In first three updates step the system clock instead of slew
# if the adjustment is larger than 10 seconds.
makestep 10 3

# Allow NTP client access from local network.
#allow 192.168/16

# Listen for commands only on localhost.
bindcmdaddress 127.0.0.1
bindcmdaddress ::1

# Serve time even if not synchronized to any NTP server.
#local stratum 10

keyfile /etc/chrony.keys

# Specify the key used as password for chronyc.
commandkey 1

# Generate command key if missing.
generatecommandkey

# Disable logging of client accesses.
noclientlog

# Send a message to syslog if a clock adjustment is larger than 0.5 seconds.
logchange 0.5

logdir /var/log/chrony
#log measurements statistics tracking
Run Code Online (Sandbox Code Playgroud)

我不知道它不会同步,我读过它需要更长的时间,但是我让我的机器静置了 1 天,但 ntp 客户端仍然没有与 ntp 服务器相同的时间(未同步) . 有任何想法吗?我尽量不要重启 chronyd 服务,让它自动同步时间

请注意,“local.ntp.server”是在我的 /etc/hosts 上定义的。此外,NTP 服务器和 NTP 客户端没有使用 ntpd 服务,而是使用 chronyd。这种设置是孤立的

bas*_*ic6 7

如果您的时间很远(几天甚至几个月),时间同步将不起作用(“这将需要很长时间”),因为像Chrony这样的 NTP 客户端通过减慢或加快时钟来逐渐调整时钟

将此行附加到您的 Chrony 配置(例如,/etc/chrony.conf/etc/chrony/chrony.conf):

makestep 1 -1
Run Code Online (Sandbox Code Playgroud)

然后重启 Chrony。

# systemctl restart chronyd
# or
# /etc/init.d/chrony restart
Run Code Online (Sandbox Code Playgroud)

解释:

makestep 指令可用于允许 chronyd 对时钟进行步进。例如,如果 chrony.conf 有

制作步骤 1 3

如果时钟的偏移量大于一秒,则时钟将在前三个更新中步进。通常,建议仅在前几次更新中允许该步骤,但在某些情况下(例如,没有 RTC 的计算机或虚拟机可以在不正确的时间挂起和恢复)可能需要在任何更新中允许该步骤时钟更新。上面的示例将更改为

使步骤 1 -1

https://chrony.tuxfamily.org/faq.html#_is_code_chronyd_code_allowed_to_step_the_system_clock


Mad*_*ter 5

你的问题似乎是你试图通过扭曲时钟来完成六年的时间变化,并在一天后放弃。

如果倾斜算法使时钟漂移百分之一(这是相当大的),那么需要六百年的时间才能使时钟倾斜那么多。即使时钟完全静止,也需要六年的时间才能倒退六年。在不到六年的时间里实现时间倒退六年的唯一方法就是让时钟倒退,我认为任何事情都不会对此做出良好反应。如果要在一天内完成这件事,就意味着时钟要以比实时速度快两千倍的速度倒退!

我的感觉是,运行撒谎的 NTP 服务器是一个非常糟糕的主意,但如果您坚持这样做,并且突然使服务器出现任何显着的偏差,则需要在客户端时钟有机会同步之前强行更改它们。这是最容易完成的,方法是确保客户端在启动时从服务器强制重置其时钟(使用ntpd,这是在启动时完成的ntpdate;我不知道 chrony)并重新启动客户端。