Linux(NTP配置)

后面也会持续更新,学到新东西会在其中补充。
建议按顺序食用,欢迎批评或者交流!
缺什么东西欢迎评论!我都会及时修改的!

NTP环境搭建

服务端客户端
192.168.111.10192.168.111.11
Linux MySQL5.7 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/LinuxLinux MySQL5.7 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
CentOS Linux release 7.9.2009 (Core)CentOS Linux release 7.9.2009 (Core)
#服务端客户端都执行
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
systemctl stop firewalld.service
systemctl disable firewalld.service

NTP服务器端安装与配置

# 安装ntpd服务
yum install ntp -y
[root@MySQL5 ~]# rpm -qa | grep ntp
ntpdate-4.2.6p5-29.el7.centos.2.x86_64
fontpackages-filesystem-1.44-8.el7.noarch
ntp-4.2.6p5-29.el7.centos.2.x86_64
#配置ntpd服务#备份文件
cp /etc/ntp.conf{,.bak}vi /etc/ntp.conf
server 127.127.1.0
fudge 127.127.1.0 startnum 10 
restrict 127.0.0.1 
restrict 192.168.111.0 netmask 255.255.255.0 
driftfile /var/lib/ntp/ 
logfile /var/log/ntp/ntp.logserver 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburstserver time1.apple.com iburst
server time2.apple.com iburst
server time3.apple.com iburst
server time4.apple.com iburst
server time5.apple.com iburstserver time1.google.com iburst
server time2.google.com iburst
server time3.google.com iburst
server time4.google.com iburstserver pool.ntp.org iburst
server cn.pool.ntp.org iburst
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server time1.aliyun.com iburst
server time2.aliyun.com iburst

在这里插入图片描述

#解释一下这些参数
#设置漂移文件路径:指定存储时钟漂移数据的文件路径。
driftfile /var/lib/ntp/drift#其中parameter的参数主要有:
#ignore   : 拒绝所有类型的ntp连接
#nomodify : 客户端不能使用ntpc与ntpq两支程式来修改服务器的时间参数
#noquery  : 客户端不能使用ntpq、ntpc等指令来查询服务器时间,等于不提供ntp的网络校时
#notrap   : 不提供trap这个远程时间登录的功能
#notrust  : 拒绝没有认证的客户端
#nopeer   : 不与其他同一层的ntp服务器进行时间同步 
restrict [address] mask [netmask_ip] [parameter]#允许本地所有操作
#restrict default nomodify notrap nopeer noquery
#允许本机使用这个时间服务器
restrict 127.0.0.1
restrict ::1
#允许允许192.168.111.0/24网段的所有主机使用该时间服务器进行时间同步
restrict 192.168.111.0 netmask 255.255.255.0 
#以本机作为时间服务器
#将本地时钟添加到 ntp.conf 文件中,以便在 NTP 服务器与 Internet 断开连接时。
#NTP 服务器提供其本地系统时钟的时间。
server 127.127.1.0 
#设置服务器层级
#Stratum 用于根据距离与服务器同步时间。Stratum-1 时间服务器充当主要的网络时间标准。
#一个stratum-2 服务器通过网络连接到stratum-1 服务器。
#因此,第 2 层服务器通过来自第 1 层服务器的 NTP 数据包请求获取其时间。
#第 3 层服务器通过来自第 2 层服务器的 NTP 数据包请求获取其时间,依此类推。
#同样,第 0 层设备始终用作参考时钟。
fudge 127.127.1.0 startnum 10 #配置NTP服务器:在文件中添加希望使用的时间源。
#可以选择多个公共NTP服务器,也可以指定企业内网NTP服务器。
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburstserver time1.apple.com iburst
server time2.apple.com iburst
server time3.apple.com iburst
server time4.apple.com iburst
server time5.apple.com iburstserver time1.google.com iburst
server time2.google.com iburst
server time3.google.com iburst
server time4.google.com iburstserver pool.ntp.org iburst
server cn.pool.ntp.org iburst
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server time1.aliyun.com iburst
server time2.aliyun.com iburst#包含其他配置文件:可以根据需要引用额外的配置文件。
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys#禁用监控功能:如果不需要启用监控功能,可以禁用它。
disable monitormkdir /var/lib/ntp/
touch /var/lib/ntp/ntp.log
systemctl start ntpd
systemctl enable ntpd
systemctl status ntpd[root@MySQL5 ~]# ps -ef | grep ntpd
ntp        1774      1  0 18:18 ?        00:00:00 /usr/sbin/ntpd -u ntp:ntp -g
root       1878   1349  0 18:41 pts/1    00:00:00 grep --color=auto ntpd[root@MySQL5 ~]# ntpstat
Unable to talk to NTP daemon. Is it running?
synchronised to local net (127.127.1.0) at stratum 6time correct to within 7948 mspolling server every 64 s
#synchronised:表示时间同步完成(ntp可以正常工作了)
#unsynchronised:表示时间同步尚未完成
ntpq -p 
[root@MySQL5 ~]# ntpstat
synchronised to local net (127.127.1.0) at stratum 6time correct to within 7948 mspolling server every 64 s
[root@MySQL5 ~]# ntpq -premote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*LOCAL(0)        .LOCL.           5 l    5   64    3    0.000    0.000   0.000
remote:远程NTP服务器的IP地址或主机名。
refid:远程NTP服务器所参考的时间源的IP地址或主机名。
st:远程NTP服务器的时钟层级(stratum)。较低的数字表示更接近时间源的服务器。
t:远程NTP服务器的时钟类型。u 表示未确定,s 表示本地挂钟,l 表示本地原子钟,f 表示外部参考源。
when:自上次成功同步以来的时间(以秒为单位)。
poll:NTP客户端向远程服务器发送时间请求的间隔(以秒为单位)。
reach:表示最近8个时间请求中成功接收到响应的数量。每个时间请求成功接收到响应时,对应的位会被设置为1。
delay:NTP客户端与远程服务器之间的往返延迟(以毫秒为单位)。
offset:NTP客户端与远程服务器之间的时间偏差(以毫秒为单位)。正值表示客户端时间比服务器时间晚,负值表示客户端时间比服务器时间早。
jitter:NTP客户端与远程服务器之间的时钟抖动(以毫秒为单位)。它表示时钟的不稳定性。

在这里插入图片描述

安装配置NTP客户端

yum install ntp ntpdate -y
[root@MySQL5 ~]# rpm -qa | grep ntp
ntp-4.2.6p5-29.el7.centos.2.x86_64
ntpdate-4.2.6p5-29.el7.centos.2.x86_64cp /etc/ntp.conf{,.bak}#修改配置文件
vi /etc/ntp.conf
#设置以192.168.111.10做为本机的时间服务器
server 192.168.111.10
#指定日志文件位置,需要手动创建
restrict 127.0.0.1
logfile /var/log/ntp/ntp.log #创建日志文件
mkdir /var/log/ntp
touch /var/log/ntp/ntp.log#先执行一次ntpdate时间同步
ntpdate 192.168.111.10

在这里插入图片描述

#启动ntpd
systemctl start ntpd
systemctl enable ntpd
systemctl status ntpd#查看同步状态,重启后需要等待一段时间,显示synchronised
#查看offset时间应该小于50ms
[root@MySQL5 ~]# ntpstat
unsynchronised #别慌!!!!!!!过一会就好!time server re-startingpolling server every 8 s
[root@MySQL5 ~]#  ntpq -premote           refid      st t when poll reach   delay   offset  jitter
==============================================================================192.168.111.10  LOCAL(0)         6 u    -   64    7    0.759    0.030   0.083

在这里插入图片描述

总结

所有结论都需要反复测试!如果有错误欢迎指正!一起努力!
如果喜欢的话,请点个赞吧就算鼓励我一下。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/8473.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

神经网络|(四)概率论基础知识-古典概型

【1】引言 前序学习了线性回归的基础知识,了解到最小二乘法可以做线性回归分析,但为何最小二乘法如此准确,这需要从概率论的角度给出依据。 因此从本文起,需要花一段时间来回顾概率论的基础知识。 【2】古典概型 古典概型是我…

21款炫酷烟花合集

系列专栏 《Python趣味编程》《C/C趣味编程》《HTML趣味编程》《Java趣味编程》 写在前面 Python、C/C、HTML、Java等4种语言实现18款炫酷烟花的代码。 Python Python烟花① 完整代码:Python动漫烟花(完整代码) ​ Python烟花② 完整…

新项目上传gitlab

Git global setup git config --global user.name “FUFANGYU” git config --global user.email “fyfucnic.cn” Create a new repository git clone gitgit.dev.arp.cn:casDs/sawrd.git cd sawrd touch README.md git add README.md git commit -m “add README” git push…

Brightness Controller-源码记录

Brightness Controller 亮度控制 一、概述二、ddcutil 与 xrandr1. ddcutil2. xrandr 三、部分代码解析1. icons2. ui3. utilinit.py 一、概述 项目:https://github.com/SunStorm2018/Brightness.git 原理:Brightness Controlle 是我在 Ubuntu 发现上调…

机器学习-K近邻算法

文章目录 一. 数据集介绍Iris plants dataset 二. 代码三. k值的选择 一. 数据集介绍 鸢尾花数据集 鸢尾花Iris Dataset数据集是机器学习领域经典数据集,鸢尾花数据集包含了150条鸢尾花信息,每50条取自三个鸢尾花中之一:Versicolour、Setosa…

Day27-【13003】短文,线性表两种基本实现方式空间效率、时间效率比较?兼顾优点的静态链表是什么?如何融入空闲单元链表来解决问题?

文章目录 本次内容总览第四节,两种基本实现方式概览两种基本实现方式的比较元素个数n大于多少时,使用顺序表存储的空间效率才会更高?时间效率比较?*、访问操作,也就是读运算,读操作1、插入,2、删…

JavaSE第十一天——集合框架Collection

一、List接口 List接口是一个有序的集合,允许元素有重复,它继承了Collection接口,提供了许多额外的功能,比如基于索引的插入、删除和访问元素等。 常见的List接口的实现类有ArrayList、LinkedList和Vector。 List接口的实现类 …

数据结构与算法学习笔记----求组合数

数据结构与算法学习笔记----求组合数 author: 明月清了个风 first publish time: 2025.1.27 ps⭐️一组求组合数的模版题,因为数据范围的不同要用不同的方法进行求解,涉及了很多之前的东西快速幂,逆元,质数,高精度等…

kaggle社区LLM Classification Finetuning

之前有个一样的比赛,没去参加,现在弄了一个无限期的比赛出来 训练代码链接:fine_tune | Kaggle 推理代码链接:https://www.kaggle.com/code/linheshen/inference-llama-3-8b?scriptVersionId219332972 包链接:pack…

【Python实现机器遗忘算法】复现2021年顶会 AAAI算法Amnesiac Unlearning

【Python实现机器遗忘算法】复现2021年顶会 AAAI算法Amnesiac Unlearning 1 算法原理 论文:Graves, L., Nagisetty, V., & Ganesh, V. (2021). Amnesiac machine learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, 115…

51单片机开发:点阵屏显示数字

实验目标:在8x8的点阵屏上显示数字0。 点阵屏的原理图如下图所示,点阵屏的列接在P0端口,行接在74HC595扩展的DP端口上。 扩展口的使用详见:51单片机开发:IO扩展(串转并)实验-CSDN博客 要让点阵屏显示数字&#xff0…

买卖股票的最佳时机 II

hello 大家好!今天开写一个新章节,每一天一道算法题。让我们一起来学习算法思维吧! 问题分析 本题要求计算在可以多次买卖股票(但任何时候最多只能持有一股股票,也可以在同一天买卖)的情况下能获得的最大…

2024年度总结——理想的风,吹进现实

2024年悄然过去,留下了太多美好的回忆,不得不感慨一声时间过得真快啊!旧年风雪尽,新岁星河明。写下这篇博客,记录我独一无二的2024年。这一年,理想的风终于吹进现实! 如果用一句话总结这一年&am…

LosslessScaling-学习版[steam价值30元的游戏无损放大/补帧工具]

LosslessScaling 链接:https://pan.xunlei.com/s/VOHc-yZBgwBOoqtdZAv114ZTA1?pwdxiih# 解压后运行"A-绿化-解压后运行我.cmd"

CVE-2020-0796永恒之蓝2.0(漏洞复现)

目录 前言 产生原因 影响范围 漏洞复现 复现环境 复现步骤 防御措施 总结 前言 在网络安全的战场上,漏洞一直是攻防双方关注的焦点。CVE-2020-0796,这个被称为 “永恒之蓝 2.0” 的漏洞,一度引起了广泛的关注与担忧。它究竟是怎样的…

计算机网络 (61)移动IP

前言 移动IP(Mobile IP)是由Internet工程任务小组(Internet Engineering Task Force,IETF)提出的一个协议,旨在解决移动设备在不同网络间切换时的通信问题,确保移动设备可以在离开原有网络或子网…

node 爬虫开发内存处理 zp_stoken 作为案例分析

声明: 本文章中所有内容仅供学习交流使用,不用于其他任何目的,抓包内容、敏感网址、数据接口等均已做脱敏处理,严禁用于商业用途和非法用途,否则由此产生的一切后果均与作者无关! 前言 主要说3种我们补环境过后如果用…

基于Python的哔哩哔哩综合热门数据分析系统的设计与实现

【Django】基于大数据的哔哩哔哩综合热门数据分析系统的设计与实现(完整系统源码开发笔记详细部署教程)✅ 目录 一、项目简介二、项目界面展示三、项目视频展示 一、项目简介 该系统涵盖登录、热门数据展示、数据分析及数据管理等功能。通过大数据处理与…

Object类(2)

大家好,今天我们继续来看看Object类中一些成员方法,这些方法在实际中有很大的用处,话不多说,来看。 注:所有类都默认继承Object类的,所以可调用Object类中的方法,如equals,也可以发生…

C++封装红黑树实现mymap和myset和模拟实现详解

文章目录 map和set的封装map和set的底层 map和set的模拟实现insertiterator实现的思路operatoroperator- -operator[ ] map和set的封装 介绍map和set的底层实现 map和set的底层 一份模版实例化出key的rb_tree和pair<k,v>的rb_tree rb_tree的Key和Value不是我们之前传统意…