配置文件说明
/etc/chronyc.conf :
#和时间服务器偏差超过1.0秒后,分3次步进完成纠正时间偏差,可以加快时间调整过程。
#chronyc默认行为是渐进调整,当时间偏差大时,缓慢调整,避免应用软件因为时间跳变而功能异常,比如定时器失效或者时间戳比较失败等问题,
makestep 1.0 3
#做为时间服务器时,允许那些网段客户端对时连接,不设置时限制客户端对时连接
allow 0.0.0.0/0
#时间服务器,iburst初始连接时,快速发送对时数据包,加快时间同步
server 10.243.31.15 iburst
常用命令
#查看时间同步服务是否正常工作
timedatectl
Local time: Wed 2023-06-28 13:55:33 CST
Universal time: Wed 2023-06-28 05:55:33 UTC
RTC time: Wed 2023-06-28 05:55:44
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
#查看时间同步服务执行情况
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
===============================================================================
^* 10.243.131.12 11 6 377 3 -18us[ -19us] +/- 272us
#立即同步时间
chronyc -a makestep
200 OK
常见问题
1、防火墙未开放UDP 123端口
2、对时服务器chronyc.conf allow的网段限制了客户端链接
资料参考
详细介绍chrony服务器
chrony 详解
chronyc命令手册
下一代时间同步服务 Chrony入门