时钟同步-注意客户端和服务端都需要开启123端口 udp协议

 确认时钟源

chronyc sources -v

chronyc tracking

Linux ❉ Chronyd时间同步服务器详解_wangjie722703的博客-CSDN博客

 local stratum 10: 即使自己未能通过网络时间服务器同步到时间,也允许将本地时间作为标准时间授时给其它客户端

确认 端口是否打开

 Nmap -sU -p 123 192.168.0.10

一文教你学会网络安全必备安全工具,轻松入门

 系统运维-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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值