AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 819467
Accepted
lemoncodes
lemoncodes
Asked: 2016-12-09 01:13:35 +0800 CST2016-12-09 01:13:35 +0800 CST 2016-12-09 01:13:35 +0800 CST

巨大时间差异上的时间同步

  • 772

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

1 月 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

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

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

ntp centos7 chrony
  • 3 3 个回答
  • 22081 Views

3 个回答

  • Voted
  1. basic6
    2018-10-04T07:30:15+08:002018-10-04T07:30:15+08:00

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

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

    makestep 1 -1
    

    然后重新启动 Chrony。

    # systemctl restart chronyd
    # or
    # /etc/init.d/chrony restart
    

    解释:

    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

    • 9
  2. Best Answer
    MadHatter
    2016-12-09T02:02:38+08:002016-12-09T02:02:38+08:00

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

    如果偏斜算法使时钟偏移多达 1%(这是相当多的),那么时钟偏斜需要六百年。即使时钟完全静止,也需要经过六年才能倒退六年。在不到六年的时间里实现六年时间倒流的唯一方法是倒计时,我认为不会有任何反应。一天之内完成这意味着以比实时速度略多两千倍的速度倒退时钟!

    我的感觉是,运行 NTP 服务器是一个非常糟糕的主意,但如果你坚持这样做,并且你突然将服务器倾斜了相当大的数量,你将需要在客户端时钟有任何同步机会之前强行更改它们. 这最容易通过确保客户端在启动时从服务器强制重置其时钟(使用ntpd,这是ntpdate在启动时完成的;我不知道 chrony)并重新启动客户端。

    • 5
  3. rvernica
    2019-03-20T16:32:48+08:002019-03-20T16:32:48+08:00

    如果时差很大chrony可能不会接受您的来源。我的时钟是几年前的,chronyc tracking它正在报告:

    > chronyc tracking
    Ref time (UTC) : Thu Jan 01 00:00:00 1970
    

    对我有用的是添加maxdistance 1000000000,/etc/chrony.conf然后(chronyd重新启动后)做chrnoyc -a makestep 1000 -1.

    • 1

相关问题

  • 网络时间服务器的 DHCP 选项

  • 公共 NTP 服务器

  • 时间同步和计划任务

  • 时间漂移

  • Windows Server 无法可靠地同步 NTP 时间

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve