<- All articles
云原生与运维1 min read

Centos服务器同步时间

对比 NTP 与 Chrony 在不同 CentOS 版本中的使用方式,记录安装、时间源配置和服务检查步骤,完成服务器时间同步。

CentOS 服务器时间同步文章封面

时间同步插件

有两种插件可以实现服务器时间同步:ntp,chrony

centos7之前的版本采用ntp进行时间同步,centos7及以后虽然ntp任然可以使用,但是官方更加推荐使用chrony

ntp安装配置

安装ntp

yum -y install ntp

配置ntp同步为阿里云服务器

vim /etc/ntp.conf
...
# aliyun
server ntp1.aliyun.com
server ntp2.aliyun.com
server ntp3.aliyun.com
...

启动ntp

systemctl start ntpd

验证ntp

ntpdate ntp1.aliyun.com

chrony安装配置

安装chrony

yum -y install chrony

配置chrony

vim /etc/chrony.conf
...
# aliyun
server ntp1.alyun.com
server ntp2.alyun.com
server ntp3.alyun.com
...

启动chrony

systemctl start chronyd

设置开机启动

systemctl start crond
systemctl enable crond

验证chrony

chronyc tracking