ntp的server端的ip为192.168.5.21 hostname为node1
server端 cat /etc/ntp.conf
[root@node1 ~]# cat /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
restrict 192.168.5.0 mask 255.255.255.0 nomodify notrap
server 127.127.1.0
fudge 127.127.1.0 stratum 8
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
client端 cat /etc/ntp.conf
[root@node2 ~]# cat /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
restrict 192.168.5.21 nomodify notrap noquery
server 192.168.5.21
fudge 127.127.1.0 stratum 8
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
配置好之后,在server端
systemctl start ntpd
在client端输入
[root@node2 ~]# ntpdate node1
7 May 15:24:59 ntpdate[31244]: adjust time server 192.168.5.21 offset 0.004936 sec
[root@node2 ~]# systemctl start ntpd
[root@node2 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.5.21 .INIT. 16 u - 64 0 0.000 0.000 0.000
说明时钟同步OK