集群中的时间同步
- 选择集群中的一台机器作为时间服务器,这里选择机器sam01
- 安装ntp
yum install ntp -y
- 查看ntp状态,可看到服务处于关闭状态
systemctl status ntpd
- 配置ntp.conf文件信息
vim /etc/ntp.conf
- 开启ntp服务
systemctl start ntpd
- ntp开机自启动
systemctl enable ntpd
- 查看ntp服务状态,为active(running),表示已经开启ntp服务
- 在其余机器上安装ntpdate
yum install ntpdate -y
- 在其余机器上与时间服务器sam01进行时间同步
ntpdate -u sam01
- 时间同步结果如下图
- 设置每隔一分钟进行时间同步
crontab -e
- 在文件中添加以下代码
* * * * * /usr/sbin/ntpdate -u sam01 > /dev/null 2>&1