Environment Introduction
Node1 as the NTP master node, all other nodes are synchronized from the Node1 time,
Node Ip
Node1 192.168.20.101
Node2 192.168.20.102
All nodes install the NTP package:
yum install ntp
- Modify the/etc/ntp.conf of the Node1 master node to add the following:
restrict 192.168.20.0 mask 255.255.255.0 nomodify notrap
That is, the server that allows the 192.168.20.0 network segment to synchronize time from that node, where 192.168.20.0 can be changed to the actual IP network segment of the environment.
3. Comment out the original time synchronization source, add local time source, that is, the external time server is not available, local time as the time service
#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 iburstserver 127.127.1.0 # local clockfudge 127.127.1.0 stratum 10
4. Start the NTP service and set the boot-up
[[email protected] ~]# systemctl start ntpd[[email protected] ~]# systemctl enable ntpdcreated symlink From/et C/systemd/system/multi-user.target.wants/ntpd.service To/usr/lib/systemd/system/ntpd.service. [[email protected] ~]# systemctl status ntpd ntpd.service-network Time service loaded:loaded (/usr/lib/systemd/ System/ntpd.service; Enabled Vendor preset:disabled) active:active (running) since Wed 2018-10-17 22:39:05 CST; 17s ago Main pid:2529 (ntpd) CGroup:/system.slice/ntpd.service└─2529/usr/sbin/ntpd-u ntp:ntp-goct 17 22: 39:05 Node1 ntpd[2529]: Listen normally on 6 lo:: 1 UDP 123Oct 22:39:05 node1 systemd[1]: Started Network time Service. OCT 22:39:05 node1 ntpd[2529]: Listen normally on 7 eno50332184 fe80::20c:29ff:fe93:4ece UDP 123Oct 22:39:05 node1 N TPD[2529]: Listen normally on 8 eno16777736 fe80::20c:29ff:fe93:4eba UDP 123Oct 22:39:05 node1 ntpd[2529]: Listen Norma Lly on 9 eno33554960 fe80::20c:29ff:fe93:4ec4 UDP 123Oct 17 22:39:05 Node1 ntpd[2529]: Listening on routing socket on FD #26 for interface updatesoct + 22:39:05 Node1 ntpd[2529]: 0.0.0.0 c016 restartoct 22:39:05 node1 ntpd[2529]: 0.0.0.0 c012 Geneva Freq_set kernel 0.000 ppmoct + 22:39:05 node1 NT PD[2529]: 0.0.0.0 c011 freq_not_setoct 22:39:06 node1 ntpd[2529]: 0.0.0.0 c514
5. Modify all other NTP clients, that is, the/etc/ntp.conf of Node2. Remove all NTP sources and add the Node1 node's NTP time source, where 192.168.20.101 is the Node1 IP and can be replaced with Node1 domain name.
#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 iburstserver 192.168.20.101
6. Start the NTP service and set the boot-up
[[email protected] ~]# systemctl start ntpd [[email protected] ~]# systemctl enable ntpd Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.serviceto /usr/lib/systemd/system/ntpd.service.
7. To see if the synchronization is successful, the following 192.168.20.101 is the IP address of the Node1 node, indicating that the synchronization was successful.
[[email protected] ~]# ntpq -p remote refid st t when poll reach delay offset jitter==============================================================================*192.168.20.101 LOCAL(0) 11 u 49 64 377 0.293 0.011 0.253
8. View actual deviations from the Node1 time server on the Node2
[[email protected] ~]# ntpdc -c loopinfooffset: 0.000011 sfrequency: 0.002 ppmpoll adjust: 6watchdog timer: 270 s
Intranet configuration NTP clock synchronization