我的任务是将linux设备与ntp服务器同步。文档表示,默认情况下,ntpd检查系统时间和服务器时间之间的差异,如果偏移量在恐慌阈值(1000 s是默认的)内,ntpd将开始缓慢地校正系统时间。好吧,这对我很好,我需要那种行为。
我手动设置系统时间,然后启动ntpd。使用命令ntpq -c对等点,我可以查找同步过程。它显示设备连接到服务器并获取数据包。但在一两分钟后,系统时间发生了变化,向服务器时间迈出了一大步。这在我的情况下是不好的,我需要慢慢的纠正。我不知道为什么会这样!
我在不同的服务器和linux中尝试了这一点,一切都一样。
设备基于raspberry pi 2,linux映像构建与内置。
# ntpd --version
ntpd 4.2.8p2@1.3265-o Fri Jul 29 11:57:46 UTC 2016 (1)
#
# uname -a
Linux buildroot 3.18.12-v7 #3 SMP PREEMPT Thu May 12 17:53:44 MSK 2016 armv7l GNU/Linux
#
# cat /etc/ntp.conf
server 10.0.0.111 #my local server
driftfile /etc/ntp.drift
logfile /var/log/ntp/ntp.log
restrict 10.0.0.111 nomodify noquery #ban any packets from server, which send to modify local time对此我找不到任何解释。所有的停顿都是关于在守护进程启动时同步时间有多快,但我需要相反。
所以,不知道.
发布于 2016-08-10 08:53:05
默认情况下,如果偏移量大于128 is,ntpd将分步(而不是直接执行)。您可以使用-x命令行选项来避免这种情况,但请注意:校正一秒钟的偏移量将花费大约2000秒,因此这可能需要很长时间。
-x Normally, the time is slewed if the offset is less than the step
threshold, which is 128 ms by default, and stepped if
above the threshold. This option sets the threshold to 600 s,
which is well within the accuracy window to set the clock
manually. Note: Since the slew rate of typical Unix kernels is
limited to 0.5 ms/s, each second of adjustment requires an
amortization interval of 2000 s. Thus, an adjustment as much as 600 s
will take almost 14 days to complete. This option
can be used with the -g and -q options.
Note: The kernel time discipline is disabled with this option.发布于 2016-08-10 06:41:07
对于一次性同步,可以使用两种不同的方法/协议:
ntpdate使用SNTP协议,而且速度非常快。ntpd -q使用NTP协议,虽然速度较慢,但更准确。https://serverfault.com/questions/795933
复制相似问题