Ntp

Chrony 似乎沒有與我指定的伺服器同步

  • March 13, 2017

我已將 Chrony 設置為與 4 個 NTP 伺服器同步(下面的配置文件)。當我執行chronyc trackingandchronyc sources時,我的機器為 NTP 連接的伺服器看起來不正確。當我詢問正在跟踪哪個伺服器以及它正在使用哪些源時,我希望看到我在 chronyd.conf 文件中指定的伺服器列表。

追踪:

$ chronyc tracking
Reference ID    : 216.152.240.220 (216.152.240.220)
Stratum         : 3
Ref time (UTC)  : Thu Feb 18 19:05:11 2016
System time     : 0.000564536 seconds fast of NTP time
Last offset     : +0.000280794 seconds
RMS offset      : 0.000322653 seconds
Frequency       : 19.616 ppm fast
Residual freq   : +0.003 ppm
Skew            : 0.053 ppm
Root delay      : 0.039604 seconds
Root dispersion : 0.000406 seconds
Update interval : 1042.6 seconds
Leap status     : Normal

資料來源:

$ chronyc sources
210 Number of sources = 4
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^+ ntp.newfxlabs.com             2  10   377   754   -415us[ -143us] +/-   31ms
^* 216.152.240.220               2  10   377   221  +1823us[+2104us] +/-   21ms
^- nox.prolixium.com             2  10   273    22  +4137us[+4137us] +/-   93ms
^- triangle.kansas.net           2  10   376   34m  -2860us[-2291us] +/-  103ms

配置文件(除了頂部的伺服器部分之外的所有預設值):

$ cat /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.rhel.pool.ntp.org iburst
##server 1.rhel.pool.ntp.org iburst
##server 2.rhel.pool.ntp.org iburst
##server 3.rhel.pool.ntp.org iburst
server 0.us.pool.ntp.org
server 1.us.pool.ntp.org
server 2.us.pool.ntp.org
server 3.us.pool.ntp.org

# 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

時間日期:

$ timedatectl
     Local time: Thu 2016-02-18 14:13:33 EST
 Universal time: Thu 2016-02-18 19:13:33 UTC
       RTC time: Thu 2016-02-18 19:13:33
      Time zone: America/New_York (EST, -0500)
    NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
     DST active: no
Last DST change: DST ended at
                 Sun 2015-11-01 01:59:59 EDT
                 Sun 2015-11-01 01:00:00 EST
Next DST change: DST begins (the clock jumps one hour forward) at
                 Sun 2016-03-13 01:59:59 EST
                 Sun 2016-03-13 03:00:00 EDT

您指定的伺服器:

server 0.us.pool.ntp.org
server 1.us.pool.ntp.org
server 2.us.pool.ntp.org
server 3.us.pool.ntp.org

顧名思義,就是pools。當您查找其中一個名稱時,您可能會獲得美國數百個公共 NTP 伺服器中的任何一個(如果您選擇其他一些國家/地區,您可能會獲得全球數千個),它們是池的一部分。這些是通過循環 DNS 傳遞的。

查看時chronyc sources,您會看到池中使用的實際伺服器。

也許您正在按池的名稱 ping 池,並認為您在響應中看到的 IP 地址與您應該在源命令的響應中看到的 IP 地址相同。

幾分鐘後再次 Ping 池,您將看到不同的 IP 地址,因為它是一個池。

別擔心,它應該可以工作,只是需要一些時間來同步。

引用自:https://serverfault.com/questions/758202