首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >大时间差下的时间同步

大时间差下的时间同步
EN

Server Fault用户
提问于 2016-12-08 09:13:35
回答 2查看 27.5K关注 0票数 6

你好,目前我有一个本地ntp服务器(chrony)和一个ntp客户机(chrony),它们都在工作,但是当我试图将ntp服务器的时间从当前时间改为负6年时。ntp客户端不能与它同步,它只会在syslog上说:

1月9日17:29:11 九一九二:系统时钟出错6780812.328260秒,调整开始

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

代码语言:javascript
复制
# 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服务器相同的时间(不同步)。有什么想法吗?am尝试不重新启动time服务,只让它自动同步时间。

注意,"local.ntp.server“是在我的/etc/主机上定义的。另外,NTP服务器和NTP客户端不使用ntpd服务,而是使用chronyd。这种设置是孤立的

EN

回答 2

Server Fault用户

回答已采纳

发布于 2016-12-08 10:02:38

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

如果倾斜算法使时钟漂移1%--这是相当多的--那么要花600年的时间才能使时钟倾斜那么多。即使时钟完全静止,也需要六年的时间才能使时钟倒退六年。在过去不到六年的时间里,实现六年倒流的唯一方法是倒转时钟,我不认为任何事情都会对此有很好的反应。要在一天内做到这一点,就意味着要以略高于实时速率两千倍的速度倒转时钟!

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

票数 5
EN

Server Fault用户

发布于 2018-10-03 15:30:15

如果您的时间很短(几天甚至几个月),时间同步将无法工作(“它将花费很长的时间”),因为NTP客户端喜欢通过减慢或加快时钟来逐步调整时钟。

将这一行追加到您的分时配置(例如,/etc/chrony.conf/etc/chrony/chrony.conf):

代码语言:javascript
复制
makestep 1 -1

那就重新开始计时。

代码语言:javascript
复制
# systemctl restart chronyd
# or
# /etc/init.d/chrony restart

解释:

makestep指令可以用来允许chronyd对时钟进行分步。例如,如果chrony.conf已经完成了步骤1 3,如果它的偏移量大于1秒,那么时钟将在前三个更新中分步执行。通常,建议只在最初几次更新时允许该步骤,但在某些情况下(例如,没有RTC或虚拟机的计算机可以挂起并在不正确的时间内恢复),可能需要允许在任何时钟更新上执行该步骤。上面的示例将更改为make步骤1 -1。

https://chrony.tuxfamily.org/faq.html#_是_代码_时间d_代码_允许的_至_步骤_这个_系统_钟

票数 9
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/819467

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档