详细可见胡图图
服务端
vi /etc/chrony.conf :编辑指定目录文件
pool 2.pool.ntp.org iburst 《将2.pool.ntp.org改为自己的ip#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
#Allow the system clock to be stepped in the first three updates
#if its offset is larger than 1 second.
makestep 1.0 3
#Enable kernel synchronization of the real-time clock (RTC).
rtcsync
#Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
#Increase the minimum number of selectable sources required to adjust
#the system clock.
#minsources 2
#Allow NTP client access from local network.
#allow 192.168.0.0/16 《删掉注释#号
#Serve time even if not synchronized to a time source.
#local stratum 10 《删掉注释#号)
systemctl restart chronyd:重启服务(服务) (重启)(服务名称)
systemctl enable chronyd:开启服务的自启动
systemctl start firewalld:启动指定服务
firewall-cmd --zone=public --add-port=123/udp --permanent:对外开放端口
firewall-cmd --reload:重载防火墙配置
firewall-cmd --list-ports:查看当前开放的端口
chronyc sources -v:查看时间服务器的状态
客户端
只用将2.pool.ntp.org改为服务端的ip
vi /etc/chrony.conf
pool 192.168.204.129 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
#Allow the system clock to be stepped in the first three updates
#if its offset is larger than 1 second.
makestep 1.0 3
#Enable kernel synchronization of the real-time clock (RTC).
rtcsync
#Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
#Increase the minimum number of selectable sources required to adjust
#the system clock.
#minsources 2
#Allow NTP client access from local network.
#allow 192.168.0.0/16
#Serve time even if not synchronized to a time source.
#local stratum 10
systemctl restart chronyd:重启服务(服务) (重启)(服务名称)
chronyc sources -v:查看时间服务器的状态