安装方式:
yum -y install ntpd
配置文件/etc/ntp.conf
ntp时间服务器:
driftfile /var/lib/ntp/drift
pidfile /var/run/ntpd.pid
restrict default ignore
restrict -6 default ignore
restrict 127.0.0.1
restrict 172.16.21.101 mask 255.255.255.0
#172.16.21.101为时间服务器
server 172.16.21.101 iburst minpoll 8 maxpoll 10
#172.16.21.101为时间服务器
server 127.127.1.0
fudge 127.127.1.0 stratum 8
#ntp服务器必须和local同步,不然客户端同步的时候会报错
客户端:
driftfile /var/lib/ntp/drift
pidfile /var/run/ntpd.pid
#logfile /var/log/ntp.log
restrict default ignore
restrict -6 default ignore
restrict 127.0.0.1
restrict 172.16.21.101 mask 255.255.255.0
#172.16.21.101为时间服务器
server 172.16.21.101 iburst minpoll 8 maxpoll 10
#172.16.21.101为时间服务器
##########同步命令(客户端操作)##############
- systemctl stop ntpd
- ntpdate 172.16.21.101
#172.16.21.101为时间服务器 - hwclock -w
#将时间写入到Bios - systemctl start ntpd
- ntpq -p
#查看同步情况