1. 安装 NTP 软件 (集群所有机器)
# yum -y install ntp
2. 配置 NTP Server (NTP 服务提供主机)
2.1 设置 NTP 服务开机自启动
# systemctl enable ntpd
# systemctl start ntpd
2.2 编辑 /etc/ntp.conf 配置文件
注释掉默认的server,添加本地server,然后重启服务
# systemctl restart ntpd
3. 配置 NTP Client (NTP服务使用主机)
3.1 禁用 NTP 服务
# systemctl disable ntpd
# systemctl stop ntpd
3.2 使用定时器作定期时间同步
# vim /etc/crontab
每隔10分钟同步一次时钟,配置如下:
*/10 * * * * root ntpdate <你的NTP服务提供主机IP> && hwclock -w
重启 crond 服务
# systemctl restart crond
至此,Client 机器的时钟会定期向 Server 同步,以保证整个集群时间一致!