Server Side#
(1) Install chrony online
yum install -y chrony
(2) Start the chrony service
systemctl start chronyd
(3) Check the status of the chrony service
systemctl status chronyd
(4) Configure the chrony service to start on boot
systemctl enable chronyd
(5) Modify the chronyd service configuration file to complete the NTP server setup
vi /etc/chrony.conf
-------------------chrony.conf-------------------
pool 2.centos.pool.ntp.org iburst
sourcedir /run/chrony-dhcp
# Multiple NTP servers configured
server ftp.aliyun.com iburst
server time1.aliyun.com iburst
server time2.aliyun.com iburst
server time3.aliyun.com iburst
server time4.aliyun.com iburst
server time5.aliyun.com iburst
server 10.10.2.103 iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
# Allowed access subnet
allow 10.10.0.0/16
keyfile /etc/chrony.keys
ntsdumpdir /var/lib/chrony
leapsectz right/UTC
# Log storage path
logdir /var/log/chrony
# Log measurement statistics
log measurements statistics tracking
-------------------chrony.conf-------------------
(6) Configure the firewall and restart the service to apply the configuration
# Configure NTP service access policy for normal access
firewall-cmd --permanent --add-service=ntp
# Reload the firewall policy
firewall-cmd --reload
# Restart the chronyd service
systemctl restart chronyd
(7) View clients connected to the NTP service
chronyc clients
Client Side#
(1) Install chrony online
yum install -y chrony
(2) Configure access to the chrony server
# Modify the chrony configuration file
vi /etc/chrony.conf
-------------------chrony.conf-------------------
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).
pool 2.centos.pool.ntp.org iburst
# Use NTP servers from DHCP.
sourcedir /run/chrony-dhcp
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Configure NTP server address
server 10.10.2.103 iburst
# Some prompt information omitted for formatting convenience
-----------------------------------------------
(3) Start the chronyd service and connect to the NTP server
# Start the chrony service
systemctl start chronyd
# Check the status of the chrony service
systemctl status chronyd
# Configure the chrony service to start on boot
systemctl enable chronyd
(4) Configure the firewall to apply the configuration
# Configure NTP service access policy for normal access
firewall-cmd --permanent --add-service=ntp
# Reload the firewall policy
firewall-cmd --reload
(5) Verify the connection status to the NTP server
# Check the status of the source server
chronyc sourcestats
# View detailed synchronization status
chronyc sources -v
# Track synchronization status
chronyc tracking
# Enable network time synchronization
timedatectl set-ntp true
# Check time synchronization status
timedatectl status