虚拟机CentOS7搭建NTP服务器及客户端同步时间

虚拟机CentOS7搭建NTP服务器及客户端同步时间

1、安装ntp包

yum -y install ntp

2、修改配置文件,使用本服务器的时间作为同步时间

vim /etc/ntp.conf

3、修改如下几步

虚拟机CentOS7搭建NTP服务器及客户端同步时间
4、启动ntp服务

systemctl start ntpd

5,查看是否同步

虚拟机CentOS7搭建NTP服务器及客户端同步时间

6、设置开机启动

systemctl enable ntpd

7,关闭防火墙和沙盒

systemctl stop firewalld
setenforce 0

8,客户端配置

安装ntp: yum -y install ntp

9、修改配置文件,将刚刚搭建好的NTP服务器作为客户端上游时间服务器

vim /etc/ntp.conf

如下图修改

虚拟机CentOS7搭建NTP服务器及客户端同步时间

10、启动ntp和设置开机自启

systemctl start ntpd
systemctl enable ntpd

与服务器同步时间

ntpdate -u 192.168.1.128

完毕!