一、配置NTP Server
1.在NTP Server 安装时间同步服务chrony
[root@ganluren network-scripts]# yum install chrony
2.启动服务并加入开机启动
[root@ganluren network-scripts]# systemctl start chronyd
[root@ganluren network-scripts]# systemctl enable chronyd
3.修改配置chrony配置文件,添加互联网时间源ntp1.aliyun.com;ntp.sjtu.edu.cn
允许allow NTP client access from local network
[root@ganluren network-scripts]# vim /etc/chrony.conf
4.查看当前时间
5.重启chrony服务
[root@ganluren network-scripts]# systemctl restart chronyd
6.再次查看时间
7.查看时间同步状态 ,*代表已同步,-代表未识别,可以进入配置文件重新添加时间源地址
[root@ganluren network-scripts]# chronyc sources -v
二、配置客户端
1.与服务端相同,安装chrony,不再详细描述
2.修改chrony.conf 配置文件,添加NTP Server地址192.168.1.251作为时间源
3.查看当前时间
4.重启服务,服务加入启动项
[root@ganluren network-scripts]# systemctl start chronyd
[root@ganluren network-scripts]# systemctl enable chronyd
5.查看时间同步状态,发现未同步
6.设置server 和客户端防火墙,开放NTP协议的UDP 123端口
[root@ganluren network-scripts]# firewall-cmd --permanent --add-port=123/udp
[root@ganluren network-scripts]# firewall-cmd --reload
7.再次查看时间同步状态,同步成功
ps :如果还是不成功,请检查服务器,客户端 chrony 版本,版本不一致可能导致同步失败