1.查看是否安装ntp服务
由于centos/redhat版本的Linux系统,默认安装的有ntpdate,但是没有ntp;
rpm -qa | grep ntp #此命令可以查看是否安装ntp服务
2.安装ntp服务
这里使用yum安装ntp服务,局域网无法连接外网,因此需要配置本地yum源
yum -y install ntp #安装ntp
3.配置vim /etc/ntp.conf (修改前请先备份)
ntp服务器端配置
<img class="alignnone wp-image-240 size-full" src="http://itdaye.com/wp-content/uploads/2021/09/ntp服务端配置.png" alt="" width="740" height="752" />
重启ntp服务器
systemctl restart ntpd
ntp客户端配置,用来测试
4.测试ntp服务器是否可用
先重置客户端时间(会把时间设置为当天的00:00:00)
date --set 20210910
在同步服务端时间
ntpdate 192.168.1.132 如下图即为成功