https://wiki.archlinux.org/index.php/Chrony
Note: systemd-timesyncd.service is in conflict with chrony, so you need to disable it first if you want to enable chrony properly.
SERVER1:
[root@r10o10405.sqa.zmf /home/ahao.mah]
#chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 10.210.208.8 4 6 377 9 +398us[ +652us] +/- 64ms
#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.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 10.210.208.8 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.
# 如果误差大于10s,前3次update时间使用step而不是slew
makestep 10 3
# Allow NTP client access from local network.
#allow 192.168/16
allow 192.168.0.0/16
allow 172.16.0.0/14
allow 10.0.0.0/8
allow 11.0.0.0/8
allow 30.0.0.0/8
#allow 10.101.75.1/22
#allow 10.101.75.1
#allow 100.64.0.0 mask 255.192.0.0
# 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
client
[root@r10o07276.sqa.zmf /home/ahao.mah]
#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.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 10.101.74.139 iburst
server 10.101.74.131 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. 简单说,如果误差大于10s,在头3次的时间更新中,会使用step,而不是slew
makestep 10 3
#makestep 1000 10
#简单说,如果误差大于1000s,在头10次的时间更新中,会使用step,而不是slew
#This would step the system clock if the adjustment is larger than 1000 seconds, but only in the first ten clock updates.
# 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
命令
client
[[root@r10o07276.sqa.zmf /home/ahao.mah]
#chronyc sources
210 Number of sources = 2
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* r10o07413.sqa.zmf.tbsite. 5 6 377 64 -415us[ -274us] +/- 62ms
^+ r10o10405.sqa.zmf.tbsite. 5 6 377 1 -947us[ -947us] +/- 63ms
[root@r10o07276.sqa.zmf /home/ahao.mah]
#chronyc sources -v
210 Number of sources = 2
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| | | zzzz = estimated error.
|| | |
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* r10o07413.sqa.zmf.tbsite. 5 6 377 1 -432us[ -702us] +/- 63ms
^+ r10o10405.sqa.zmf.tbsite. 5 6 377 2 -678us[ -947us] +/- 63ms
[root@r10o07276.sqa.zmf /home/ahao.mah]
#chronyc sourcestats
210 Number of sources = 2
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
==============================================================================
r10o07413.sqa.zmf.tbsite. 6 3 325 -0.550 6.451 -232us 161us
r10o10405.sqa.zmf.tbsite. 7 3 387 +0.702 11.702 +235us 541us
[root@r10o07276.sqa.zmf /home/ahao.mah]
#chronyc sourcestats -v
210 Number of sources = 2
.- Number of sample points in measurement set.
/ .- Number of residual runs with same sign.
| / .- Length of measurement set (time).
| | / .- Est. clock freq error (ppm).
| | | / .- Est. error in freq.
| | | | / .- Est. offset.
| | | | | | On the -.
| | | | | | samples.
| | | | | | |
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
==============================================================================
r10o07413.sqa.zmf.tbsite. 6 3 325 -0.550 6.451 -233us 161us
r10o10405.sqa.zmf.tbsite. 7 3 387 +0.702 11.702 +237us 541us
[root@r10o10405.sqa.zmf /home/ahao.mah]
#chronyc tracking
Reference ID : 10.210.208.8 (10.210.208.8)
Stratum : 5
Ref time (UTC) : Fri Feb 17 09:53:47 2017
System time : 0.000000227 seconds slow of NTP time
Last offset : +0.000335872 seconds
RMS offset : 0.000938629 seconds
Frequency : 23.669 ppm slow
Residual freq : +0.560 ppm
Skew : 10.502 ppm
Root delay : 0.067548 seconds
Root dispersion : 0.030173 seconds
Update interval : 64.5 seconds
Leap status : Normal