CentOS 7 使用 Chrony 自动同步时间

Author Avatar
青枫 2021年09月03日
  • 在其它设备中阅读本文章

1. 安装 chrony

yum install chrony -y

2. 配置 Chrony 服务

一般来说,配置文件无需改动就能正常使用。当然为了加快同步速度,可以使用国内的 NTP 服务器。

vi /etc/chrony.conf

chrony.conf

将 pool 2.centos.pool.ntp.org iburst 修改为 pool time.pool.aliyun.com iburst

更多公共 NTP 服务器请参考: 公共 NTP 服务器地址大全

3. 启动 chronyd 服务并设置开机自启动

systemctl start chronyd.service
systemctl enable chronyd.service

相关常用命令

1. 查看系统时间

date

2. 强制同步系统时间

chronyc -a makestep

3. 查看时间同步源

chronyc sources -v

4. 查看时间同步源状态

chronyc sourcestats -v