安装服务
yum install chrony -y
systemctl enable chronyd ###设置开机默认启动
修改配置
[[email protected] ~]# vi /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#pool 2.centos.pool.ntp.org iburst
#pool time1.aliyun.com iburst
#pool time2.aliyun.com iburst
#pool time3.aliyun.com iburst
server time1.aliyun.com iburst ###外部时间服务器
server time2.aliyun.com iburst
server time3.aliyun.com iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
#allow 192.168.0.0/16
allow all ###允许任何链接
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys
# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
启动服务
systemctl restart chronyd
配置防火墙
firewall-cmd --zone=public --add-port=123/udp --permanent
firewall-cmd --reload
其他服务器测试
安装启动服务器
yum install chrony -y
systemctl enable chronyd ###设置开机默认启动
修改配置
vi /etc/chrony.conf
注释原有配置,修改为刚才安装服务器
#pool 2.centos.pool.ntp.org iburst
server 100.40.10.3 iburst
测试同步成功
[[email protected] ~]# chronyc sources -v
210 Number of sources = 1
.-- 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
===============================================================================
^? pool-100-40-10-3.prvdri.> 0 10 0 - +0ns[ +0ns] +/- 0ns
引用
https://blog.csdn.net/dhcp_zhao/article/details/102926399#chronyconf_13
https://www.cnblogs.com/lianglab/p/14088050.html