Note: the system environment is centos7. The hierarchical relationship of NTP is not described here

One: set the host time and timely zone

Ensure that the localtime zone of the host is correct: set localtime: # timeDatectl set-timezone “Asia/Shanghai” Set hardware clock to coordinated Universal Time (UTC) # timedatectl set-local-rTC 0 Set hardware time, Hwclock –systohc Enable NTP # timeDatectl set-ntp true

2: Install the NTP service

Yum install NTP or yum localinstall./* manually synchronize time with the upper-layer clock source on the host to be set as the NTP server: ntpdate -u *.*.*.*(corporate or international clock source or IP address)

Configuring the NTP server:

Vi /etc/ntp.conf Add the following configuration: # Restrict 192.168.1.0 Mask 255.255.255.0 nomodify notrap # Add upper-layer server H3CNtp02-in.h3c.com RESTRICT H3cntp02-in.h3c.com Nomodify notrap noQuery



# systemctl start ntpd



# systemctl enable ntpd






ntpq -p



ntpstat





Configuring the NTP client:

Vi /etc/ntp.conf Add the following configuration: # Add upper-layer server H3CNtp02-in.h3c.com RESTRICT H3CNtp02-in.h3c.com nomodify notrap noquery



# systemctl start ntpd



# systemctl enable ntpd






ntpq -p



ntpstat












Main reference links: blog.csdn.net/sinat_31726… Encountered the following error: the NTP socket is in use, exiting solution reference: blog.csdn.net/Primeprime/… Ps – ef | grep XNTPD, the related process kill lsof – I: 123, the related process kill note: The preceding systems have the Chrony service, which conflicts with the NTP service. After the NTP service is installed and time synchronization verification is enabled, you need to disable the Chrony service. Otherwise, the NTP service cannot start after the system restarts. Systemctl stop chronyd Systemctl disable chronyd

Reference links: blog.csdn.net/u013712826/… www.cnblogs.com/zhi-leaf/p/…