在 CentOS Minimal(最小化安装)下同步时间,通常有以下几种方式,取决于你使用的 CentOS 版本(CentOS 7 / 8 / Stream)。
chrony(推荐,CentOS 7/8 默认)yum install -y chrony
systemctl start chronyd
systemctl enable chronyd
chronyc -a makestep
chronyc tracking
默认使用 CentOS 官方 NTP 服务器,通常无需修改配置。
ntpdate(快速一次性同步)yum install -y ntpdate
ntpdate pool.ntp.org
或国内服务器:
ntpdate cn.pool.ntp.org
⚠️
ntpdate已逐步被弃用,不建议长期依赖。
timedatectl(CentOS 7+)timedatectl
timedatectl set-ntp true
timedatectl set-timezone Asia/Shanghai
如果使用 NTP 服务,需要放行 UDP 123:
firewall-cmd --add-service=ntp --permanent
firewall-cmd --reload
(Minimal 默认通常无防火墙)
systemctl enable --now chronyd
Asia/Shanghaidate
✅ CentOS Minimal 最佳实践:
yum install -y chrony
systemctl enable --now chronyd
timedatectl set-timezone Asia/Shanghai
如果你告诉我 CentOS 具体版本(7 / 8 / Stream),我可以给你更精确的命令。