确认时钟源
chronyc sources -v
chronyc tracking
Linux ❉ Chronyd时间同步服务器详解_wangjie722703的博客-CSDN博客
local stratum 10: 即使自己未能通过网络时间服务器同步到时间,也允许将本地时间作为标准时间授时给其它客户端
确认 端口是否打开
Nmap -sU -p 123 192.168.0.10
Nmap是一款功能强大的网络探测和安全评估工具,是渗透测试和网络安全评估中必不可少的工具之一.
一文教你学会网络安全必备安全工具,轻松入门
系统运维-Linux使用Chrony实现NTP时钟同步服务_拾柒SHY的博客-CSDN博客
转载:系统运维-Linux使用Chrony实现NTP时钟同步服务
Chrony:是一个开源自由的网络时间协议NTP的服务端和客户端软件 它能使服务端系统时间保持与服务器系统时间同步
实验环境
服务端:192.168.100.200
客户端:192.168.100.10
首先一般默认都是已安装在Linux系统中的 若没有安装 则执行安装
yum install chrony* -y
然后编辑服务端的chrony配置文件
vim /etc/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.pool.ntp.org iburst //注释此行
server 192.168.100.200 iburst //添加此行 server+服务端ip+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.100.0/24 //要设置允许的网络段
# Serve time even if not synchronized to a time source.
local stratum 10 //取消注释此行
# Require authentication (nts or key option) for all NTP sources.
#authselectmode require
# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys
# Save NTS keys and cookies.
ntsdumpdir /var/lib/chrony
# Insert/delete leap seconds by slewing instead of stepping.
#leapsecmode slew
# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
服务器端就配置完成了 接下来保存退出
配置客户端
vim /etc/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.pool.ntp.org iburst //注释此行
server 192.168.100.200 iburst //添加此行 server+服务端ip+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
# Require authentication (nts or key option) for all NTP sources.
#authselectmode require
# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys
# Save NTS keys and cookies.
ntsdumpdir /var/lib/chrony
# Insert/delete leap seconds by slewing instead of stepping.
#leapsecmode slew
# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
客户端也就配置完成了 接下来重启并设置自启服务端和客户端的chrony
systemctl restart chronyd #重启chrony
systemctl enable chronyd #设置自启
接下来客户端查看同步情况
chronyc sources #客户机查看同步源
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.100.200 10 10 377 759 -8687ns[-9982ns] +/- 227us #同步成功
就同步成功了 如果同步失败检查是否关闭了selinux和firewalld
————————————————
版权声明:本文为CSDN博主「拾柒SHY」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/m0_60984906/article/details/128552398