-
安装Chrony服务(Rocky Linux 8+默认替代NTP的工具):
sudo dnf install chrony
-
配置NTP服务器: 编辑配置文件
/etc/chrony.conf
,注释或删除原有pool
行,添加国内常用NTP服务器(例):server ntp.aliyun.com iburst server ntp.tencent.com iburst
-
启动并设置开机自启:
sudo systemctl enable --now chronyd
-
验证同步状态:
chronyc sources -v # 查看源状态 chronyc tracking # 检查同步精度
-
防火墙放行(若启用):
sudo firewall-cmd --add-service=ntp --permanent sudo firewall-cmd --reload
异常处理:
- 若时间偏差大,先执行
sudo chronyc makestep
强制同步 - 检查时区设置:
timedatectl set-timezone Asia/Shanghai