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

news/2024/7/5 10:32:34

 确认时钟源

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


http://lihuaxi.xjx100.cn/news/1137279.html

相关文章

【案例教程】Biome-BGC生态系统模型与Python融合技术应用

Biome-BGC是利用站点描述数据、气象数据和植被生理生态参数,模拟日尺度碳、水和氮通量的有效模型,其研究的空间尺度可以从点尺度扩展到陆地生态系统。 在Biome-BGC模型中,对于碳的生物量积累,采用光合酶促反应机理模型计算出每天…

vue页面无操作返回登录页

方法一、挂在定时器 const timing ref(1000 * 60 * 20)const timer ref(null)document.addEventListener(keyup, () > {timing.value 1000 * 60 * 20})document.addEventListener(mousemove, () > {timing.value 1000 * 60 * 20})timer.value setInterval(() > {…

可视化大屏适配/自适应现状

可视化大屏适配/自适应现状 三大常用方式 vw/vh方案 概述:按照设计稿的尺寸,将px按比例计算转为vw和vh 优点:可以动态计算图表的宽高,字体等,灵活性较高,当屏幕比例跟 ui 稿不一致时,不会出现两…

Agisoft Metashape 基于影像的外部点云着色

Agisoft Metashape 基于影像的外部点云着色 提示:这里可以添加系列文章的所有文章的目录,目录需要自己手动添加 例如:第一章 Python 机器学习入门之pandas的使用 提示:写完文章后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 Agisoft Metashape 基于影像的外…

Git分支管理策略与发布流程及版本控制

Git是一个分布式版本控制系统,用于跟踪和管理项目的代码变更。它具有高效、灵活、强大的特性,被广泛应用于软件开发领域。 Git的优势: 分布式版本控制:每个开发者都有一个完整的代码仓库,可以在本地进行提交、分支和合…

掌握无缝云迁移方法的数据集成

随着越来越多的组织过渡到基于云的基础架构,数据集成已成为云迁移过程的关键组成部分。数据集成包括将来自不同来源的数据集成到一个整合的视角中。云迁移的上下文涉及将数据从本地系统传输到基于云的平台,同时确保数据的一致性、准确性和可用性。 本文…

港联证券|新能源大金融双主线发力 沪指探低回升收复3300点

周一,A股三大指数呈现宽幅震荡走势。沉寂许久的新能源板块早盘复苏,保险、券商与部分“中字头”股票午后发力,多主线并进带动市场普涨。截至收盘,上证综指报3310.74点,涨1.17%;深证成指报11178.62点&#x…

小程序点击导航栏返回顶部小例子

<view class"headerTop" id"headerTop" click"onNavigationBarTap">顶部导航栏 </view> //样式 width: 100%; position: fixed; background: white; left: 0; z-index: 999;//jslastTapTime: null,//用于记录上一次点击的时间戳scr…