注意:从 CentOS 7.2&RHEL 7.0 开始实现时间同步的程序默认从 NTP 换成了 Chrony 。 NTP 也可以继续使用,但是需要单独安装 NTP 的安装包。
步骤一:系统环境要求
(1)服务器的系统是 CentOS 6.X 版本
(2)服务器系统需要有 yum 源
步骤二:确保 ntp 已经安装
# yum -y install ntp
步骤三:确保系统会使用 Chrony 或 NTP 的时间同步
# timedatectl set-ntp true
# timedatectl
Local time: Fri 2020-06-12 09:52:30 EDT
Universal time: Fri 2020-06-12 13:52:30 UTC
RTC time: Fri 2020-06-12 13:51:52
Time zone: America/New_York (EDT, -0400)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
步骤四:修改配置文件
# vim /etc/sysconfig/ntp
将部分内容修改如下:
......
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
(说明:在配置文件的末尾添加要进行时间同步的服务器)
步骤五:重启客户端的 ntp 服务
# service ntpd restart
# service ntpd status
步骤六:查看客户端时间同步的状态
# ntpq -p