集群中的时间同步

  1. 选择集群中的一台机器作为时间服务器,这里选择机器sam01
  2. 安装ntp
yum install ntp -y
  1. 查看ntp状态,可看到服务处于关闭状态
systemctl status ntpd

image


  1. 配置ntp.conf文件信息
vim /etc/ntp.conf

image


  1. 开启ntp服务
systemctl start ntpd
  1. ntp开机自启动
systemctl enable ntpd
  1. 查看ntp服务状态,为active(running),表示已经开启ntp服务

image


  1. 在其余机器上安装ntpdate
yum install ntpdate -y
  1. 在其余机器上与时间服务器sam01进行时间同步
ntpdate -u sam01
  1. 时间同步结果如下图

image


  1. 设置每隔一分钟进行时间同步
crontab -e

image


  1. 在文件中添加以下代码
* * * * * /usr/sbin/ntpdate -u sam01 > /dev/null 2>&1

image

posted @ 2022-02-13 21:45  递茶大户  阅读(160)  评论(0编辑  收藏  举报