yum install ntp
rpm -qa | grep ntp
配置文件中没有server开头的配置,如果有需要注释掉
vim /etc/ntp.conf
server 127.127.1.0
fudge 127.127.1.0 stratum 10
#10.0.0.0改为你的网络
restrict 10.0.0.0 mask 255.255.255.0 nomodify notrap # nomodify表示客户端不能更改服务器端的时间参数
启动服务
systemctl restart ntpd
systemctl enable ntpd
systemctl status ntpd
服务端配置后要等5分钟再配置客户端和同步时间数据。否则会报错。
客户端配置
yum install ntp
vim /etc/ntpd.conf
server 你的ntpd服务器ip
systemctl restart ntpd
也可以设置crontab同步,通过ntpdate IP来同步时间