环境介绍
两台centos7
192.168.5.129
192.168.5.133
首先server端安装ntp
Yum -y install ntp
修改配置文件
Vi /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 127.127.1.0 iburst
server 127.127.1.0 fudge
127.127.1.0 stratum 8
server ntp.ntsc.ac.cn
server cn.ntp.org.cn
重启ntp服务
Systemctl restart ntpd
客户机安装ntpdate
Yum -y install ntpdate
Ntpdate -u 192.168.5.129
Server端同步系统时间
Date -s ‘13:58:00 2021-6-17’
[root@localhost ~]# date -s '2021-6-17 14:48:00'
2021年 06月 17日 星期四 14:48:00 CST
[root@localhost ~]# ntpdate -u 192.168.5.133
17 Jun 14:48:24 ntpdate[21808]: no server suitable for synchronization found
[root@localhost ~]# date
2021年 06月 17日 星期四 14:48:26 CST
s