13 Nov 16:18:35 ntpdate [3332]: the NTP socket is in use, exitingNote: If the ntpd service is enabled, you must disable the ntpd service before using it.
4. modify the configuration file
[Root @ ntpserver ~] # Vim/etc/ntp. conf // Add the highlighted red part
Restrict default kod nomodify notrap nopeer noquery // The Service rejects all NTP connections by default.
Restrict-6 default kod nomodify notrap nopeer noquery // reject all NTP connections of IPV6
Restrict 127.0.0.1
Restrict-6: 1 // the above two indicate that local access is allowed
Restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap
// When a host with the IP address range of 192.168.0.0/24 is allowed to perform this operation, the client is not allowed to modify it and the ntp server is logged on.
# Server 0.centos.pool.ntp.org
# Server 1.centos.pool.ntp.org
# Server 2.centos.pool.ntp.org
# Server 3.centos.pool.ntp.org
Server 1.cn.pool.ntp.org
Server 2.cn.pool.ntp.org prefer // prefer is preferred
Logfile/var/log/ntp. log
5. Synchronously update hwclock
[Root @ ntpserver ~] # Vim/etc/sysconfig/ntpd
SYNC_HWCLOCK = yes
6. Start the ntp service.
[Root @ ntpserver ~] # Service ntpd start
7. view the connection status with the upper-layer server
[Root @ ntpserver ~] # Ntpq-p
Remote refid st t when poll reach delay offset jitter
========================================================== ================================
+ News.neu.edu.cn 202.118.1.46 2 u 14 128 377 44.480 2.868
* 202.118.1.130 202.118.1.46 2 u 63 128 377 41.726 1.631
LOCAL (0). LOCL. 10 l 9 64 377 0.000 0.000
Note: * indicates the upper-layer NTP currently in use. + indicates that the server is connected and the backup server with time update is available.
8. Confirm that synchronization has been performed.
[Root @ ntpserver ~] # Ntpstat // it takes several minutes to display the following time
Synchronised to NTP server (202.118.1.130) at stratum 3
Time correct to within 60 MS
Polling server every 128 s
9. Add to start
[Root @ ntpserver ~] # Chkconfig ntpd on
Iv. Client settings
1. Synchronization time
[Root @ linux ~] # Ntpdate 192.168.0.128
13 Nov 16:41:52 ntpdate [3293]: adjust time server 192.168.0.128 offset 0.003880 sec
2. Join the task plan
[Root @ linux ~] # Crontab-e // synchronize every morning
0 1 ***/usr/sbin/ntpdate 192.168.0.128