
1、背景
Rocky Linux 9

在执行时间同步时遇到了问题。从错误信息可以看出,**
systemd-timesyncd
服务在您的系统上不存在** 。这在 Rocky Linux 9 中是正常现象,因为 Rocky Linux 默认使用chronyd
而不是systemd-timesyncd
。
2、原因
服务名称错误 :Rocky Linux 9 使用
chronyd
而不是systemd-timesyncd
服务未安装:可能系统初始安装时没有包含时间同步服务
命令拼写错误 :您输入的
timedatctl
应该是timedatectl
3、解决办法
第一步:安装并配置 chrony 时间同步服务
# 安装 chrony(如果尚未安装) dnf install -y chrony # 启动并启用 chrony 服务 systemctl enable --now chronyd # 强制立即同步时间 chronyc makestep
第二步:验证时间同步状态
# 检查时间同步状态 timedatectl status # 查看 chrony 同步状态 chronyc tracking # 查看时间源 chronyc sources
第三步:校正当前系统时间(关键步骤)
# 手动设置正确时间(以当前时间为例) date -s "2024-01-16 20:30:00" # 请替换为实际当前时间 # 将系统时间写入硬件时钟 hwclock --systohc
📋 完整的修复流程
# 1. 停止可能存在的错误时间服务 systemctl stop chronyd 2>/dev/null || true # 2. 安装 chrony dnf install -y chrony # 3. 配置可靠的 NTP 服务器 cat > /etc/chrony.conf << EOF server ntp.aliyun.com iburst server ntp1.aliyun.com iburst server ntp2.aliyun.com iburst EOF # 4. 启动服务并强制同步 systemctl enable --now chronyd chronyc makestep # 5. 验证时间是否正确 date timedatectl status # 6. 现在可以正常安装软件了 dnf install -y nfs-utils rpcbind
