dnf install -y chrony
/etc/chrony.conf,以下介绍常用配置项。/etc/chrony.conf,修改 server 配置项:vi /etc/chrony.conf
# NTP 服务器(腾讯云内部)server time1.tencentyun.com iburstserver time2.tencentyun.com iburstserver time3.tencentyun.com iburstserver time4.tencentyun.com iburstserver time5.tencentyun.com iburst# 腾讯公网 NTP 服务器server ntp.tencent.com iburstserver ntp1.tencent.com iburstserver ntp2.tencent.com iburstserver ntp3.tencent.com iburst# 公共 NTP 服务器(备用)server cn.pool.ntp.org iburst
# NTP 服务器(腾讯云内部)server time1.tencentyun.com iburstserver time2.tencentyun.com iburstserver time3.tencentyun.com iburstserver time4.tencentyun.com iburstserver time5.tencentyun.com iburst# 腾讯公网 NTP 服务器server ntp.tencent.com iburstserver ntp1.tencent.com iburstserver ntp2.tencent.com iburstserver ntp3.tencent.com iburst# 时钟漂移记录文件driftfile /var/lib/chrony/drift# 允许步进校时(前3次同步若偏差超过1秒则直接跳变)makestep 1.0 3# 将系统时钟写回硬件时钟rtcsync# 从系统时区数据库获取 TAI-UTC 偏移leapsectz right/UTC# 日志目录logdir /var/log/chrony
参数 | 说明 |
server <地址> iburst | 指定 NTP 服务器,iburst 加速初次同步(头四次请求间隔缩短为 2 秒) |
driftfile <路径> | 记录时钟漂移补偿值的文件,默认 /var/lib/chrony/drift |
makestep 1.0 3 | 前3次同步偏差超过1秒时直接步进校时 |
rtcsync | 将系统时钟同步到硬件时钟(RTC) |
logdir <路径> | 日志目录,默认 /var/log/chrony |
# 启动 chronyd 服务systemctl start chronyd# 设置开机自启动systemctl enable chronyd# 查看服务状态systemctl status chronyd# 重启服务(修改配置后)systemctl restart chronyd
chronyc tracking
Reference ID : A9FE0050 (169.254.0.80)Stratum : 3Ref time (UTC) : Fri Aug 21 07:08:58 2026System time : 0.000010930 seconds fast of NTP timeLast offset : +0.000018760 secondsRMS offset : 0.000018760 secondsFrequency : 23.578 ppm slowResidual freq : -1.007 ppmSkew : 39.788 ppmRoot delay : 0.001493059 secondsRoot dispersion : 0.031474017 secondsUpdate interval : 2.0 secondsLeap status : Normal
chronyc sources -v
MS Name/IP address Stratum Poll Reach LastRx Last sample===============================================================================^+ 169.254.0.79 2 6 77 11 +635us[ +635us] +/- 42ms^+ 169.254.0.80 2 6 77 11 +649us[ +649us] +/- 43ms^+ 169.254.0.81 2 6 77 12 +440us[ +440us] +/- 30ms^+ 169.254.0.82 2 6 77 11 +515us[ +515us] +/- 37ms^* 169.254.0.83 2 6 77 13 +640us[ +879us] +/- 42ms
标记 | 含义 |
* | 当前正在使用的同步源 |
+ | 已选中的备用源 |
- | 已排除(不参与当前同步) |
? | 无法联系的源 |
chronyc sourcestats -v
chronyc activity
200 OK10 sources online0 sources offline0 sources doing burst (return to online)0 sources doing burst (return to offline)0 sources with unknown address
chronyc makestep
journalctl -u chronyd
timedatectl
Local time: 五 2026-08-21 15:14:24 CSTUniversal time: 五 2026-08-21 07:14:24 UTCRTC time: 五 2026-08-21 07:14:24Time zone: Asia/Shanghai (CST, +0800)System clock synchronized: yesNTP service: activeRTC in local TZ: no
timedatectl list-timezones | grep Asia
timedatectl set-timezone Asia/Shanghai
timedatectl set-ntp true
# 1. 确认 chronyd 运行正常systemctl is-active chronyd# 2. 确认已与 NTP 服务器同步(System time 应小于 1 秒)chronyc tracking | grep "System time"# 3. 确认时区正确date
chronyc tracking 显示 "Not synchronised"# 查看 chronyd 日志排查网络问题journalctl -u chronyd -n 50# 测试 NTP 服务器连通性ping -c 4 time1.tencentyun.com# 检查防火墙是否放行 UDP 123 端口firewall-cmd --list-all | grep ntp
firewall-cmd --permanent --add-service=ntpfirewall-cmd --reload
# 立即强制同步(谨慎在有强一致性要求的系统上操作)chronyc makestep# 查看偏差量chronyc tracking | grep offset
/etc/chrony.conf 中将 makestep 参数调整为不限次数步进:# 只要偏差超过 1 秒就步进校时(不限次数)makestep 1.0 -1
文档反馈