ntp时钟服务安装- 局域网节点时间同步

场景:

  • 一般部署大数据相关应用服务,各个节点之间需要时间同步
  • 内网情况下,很可能各节点之前时间可能不一致,或者过一段时间后 又不一致了

ntp 时钟服务器:

  • 可用于内网各个节点之前得时间同步,安全方便。
  • 大致有个 ntp-server 各个 节点有个 ntp-client 间隔一段时间就去同步 服务端得时间。

流程图:
1

安装配置:
centos7-rpm包分享下载

在有网环境自我导出:
yum install --downloadonly --downloaddir=/opt compat-openssl ntp ntpdate

# 各个节点安装
rpm -ivh compat-openssl10-1.0.2o-3.el8.x86_64.rpm
rpm -ivh ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm
rpm -ivh ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm  

配置文件修改- server端

  • vi /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).

driftfile /var/lib/ntp/drift

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery

# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1

# Hosts on local network are less restricted.
# 同步ip断, 设置同步ip断 1
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap
# 同步ip断, 设置同步ip断 2
restrict 177.180.110.0 mask 255.255.255.0 nomodify notrap

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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 iburst
# 联网时配置
server 0.cn.pool.ntp.org
server 1.cn.pool.ntp.org
server 2.cn.pool.ntp.org
server 3.cn.pool.ntp.org

restrict 0.cn.pool.ntp.org nomodify notrap noquery
restrict 1.cn.pool.ntp.org nomodify notrap noquery
restrict 2.cn.pool.ntp.org nomodify notrap noquery
restrict 3.cn.pool.ntp.org nomodify notrap noquery
# 外部时间服务器不可用时,以本地时间作为时间服务
server 127.127.1.0
fudge 127.127.1.0 stratum 10

#broadcast 192.168.1.255 autokey        # broadcast server
#broadcastclient                        # broadcast client
#broadcast 224.0.1.1 autokey            # multicast server
#multicastclient 224.0.1.1              # multicast client
#manycastserver 239.255.254.254         # manycast server
#manycastclient 239.255.254.254 autokey # manycast client

# Enable public key cryptography.
#crypto

includefile /etc/ntp/crypto/pw

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8

# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats

# Disable the monitoring facility to prevent amplification attacks using ntpdc
# monlist command when default restrict does not include the noquery flag. See
# CVE-2013-5211 for more details.
# Note: Monitoring will not be disabled with the limited restriction flag.
# 运行修改硬件时间
SYNC_HWCLOCK=yes
disable monitor

ntp 客户端配置:

  • vi /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).

driftfile /var/lib/ntp/drift

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery

# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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 iburst
# 从配置的时钟服务器中同步时间,服务端ip
server 177.180.20.10
# 允许修改本地时间
restrict 177.180.20.10 nomodify notrap noquery
# 如果时间服务器不可用,用本地的时间服务
server 127.127.1.0
fudge 127.127.1.0 stratum 10
#broadcast 192.168.1.255 autokey        # broadcast server
#broadcastclient                        # broadcast client
#broadcast 224.0.1.1 autokey            # multicast server
#multicastclient 224.0.1.1              # multicast client
#manycastserver 239.255.254.254         # manycast server
#manycastclient 239.255.254.254 autokey # manycast client

# Enable public key cryptography.
#crypto

includefile /etc/ntp/crypto/pw

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8

# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats

# Disable the monitoring facility to prevent amplification attacks using ntpdc
# monlist command when default restrict does not include the noquery flag. See
# CVE-2013-5211 for more details.
# Note: Monitoring will not be disabled with the limited restriction flag.
SYNC_HWCLOCK=yes
disable monitor

启动配置:

  • 先启动 服务端得 ntp-server ,再启动各节点 ntp-client;
  • systemctl status ntpd
  • systemctl start ntpd
  • systemctl enable ntpd
  • ntpdate ${ntp-server-ip} - 各节点可先,手动同步一次

查看命令:

  • ntpq -p //查看网络中的NTP服务器,同时显示客户端和每个服务器的关系
  • ntpstat //ntp 客户端,查看时间同步状态

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

动态规划|【路径问题】63.不同路径II

目录 题目 题目解析 动态规划思路 1.状态表示 2.状态转移方程 3.初始化 4.填表顺序 5.返回值 代码 题目 63. 不同路径 II 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为 “Start” )。 机器人每次只能向下或者向右移动一步。…

小狐狸chat2.7.2免授权修复版可用版

小狐狸chat2.7.2免授权修复版可用版 在网络上面找了好几个版本不能使用,今天发布这个仔细测试正常使用 主要功能:独立版无限多开支持分销会员充值自己APP打包小程序万能创作MJ绘图多个国内接口 国外很火的ChatGPT,这是一种基于人工智能技术…

SpringBoot整合rabbitmq-直连交换机队列(二)

说明:本文章主要是Direct定向/直连类型交换机的使用,它的大致流程是将一个队列绑定到一个直连交换机上,并赋予一个路由键 routingkey,当一个消息携带着路由值为routingkey,这个消息通过生产者发送给交换机时&#xff0…

Android进阶之路 - RecyclerView停止滑动后Item自动居中(SnapHelper辅助类)

之前一直没注意 SnapHelper 辅助类的功能,去年的时候看到项目中仅通过俩行代码设置 RecyclerView 后就提升了用户体验,觉得还是很有必要了解一下,尝试过后才发现其 PagerSnapHelper、LinearSnapHelper 子类可以作用于不同场景,且听…

操作系统—xv6内核环境配置

文章目录 xv6内核环境配置1.开发环境的准备(1).如果日常用Linux(2).Windows的回合#1.两个常见方法#2.wsl的一点安装细节#3.记得升级成wsl-2 (3).如果你是macOS#1.一些起因#2.最乐的一集#3.Homebrew的配置#4.mac用户的特权 2.先换apt源3.安装xv6的依赖4.克隆RISC-V GNU 编译器工…

ICLR/NeurIPS论文分享:任务通用的时序基础模型

吴海旭 清华大学软件学院博士生 师从龙明盛副教授,研究方向为深度学习及其在复杂时空物理过程建模中的应用,目前在Nature Machine Intelligence、IEEE TPAMI、ICML、NeurIPS上发表多篇论文,研究成果在中国气象局、北京冬奥会落地应用。曾获清…

【低代码开发_RuoYi_框架】RuoYi框架_前端页面部署/搭建

开源软件的影响力 随着信息技术的快速发展,开源软件已经成为软件开发的趋势,并产生了深远的影响。开源软件的低成本、可协作性和透明度等特点,使得越来越多的企业和个人选择使用开源软件,促进了软件行业的繁荣。然而,…

【Linux深入剖析】再续环境变量 | 进程地址空间

📙 作者简介 :RO-BERRY 📗 学习方向:致力于C、C、数据结构、TCP/IP、数据库等等一系列知识 📒 日后方向 : 偏向于CPP开发以及大数据方向,欢迎各位关注,谢谢各位的支持 目录 1.环境变量再续1.1 和…

visio、ppt、office等另存图片,如何设置更清晰

visio、ppt、office等另存图片,如何设置更清晰 选中要另存为的部分——文件——另存为——选好位置——格式选jpg——保存——按下图设置:质量100%,分辨率选打印机,大小选屏幕——确定

Linux:Kubernetes(k8s)——基础理论笔记(1)

我笔记来源的图片以及共享至GitHub,本章纯理论。这是k8s中部分的基础理论 👇 KALItarro/k8spdf: 这个里面只有一个pdf文件 (github.com)https://github.com/KALItarro/k8spdf👆 什么是kubernetes kubernetes 是一个开源的,用于管…

COMPOSER安装使用WIN下升级PHP-V

想用TP6使用phpspreadsheet但是说我PHP版本低,原来是PHP7.0 composer要求至少7.4 直接修改环境变量,把PHP目录切换到7.4 composer升级比较简单,在PHP目录下CMD然后官网的命令执行下即可 下面就可以在TP根目录下执行命令安装PHPSPREADSHEET…

MyBatis 学习(二)之 第一个 MyBatis 案例

目录 1 配置 MyBatis 方式 1.1 XML 配置文件 1.2 Java 注解配置 1.3. Java API 配置 2 在 MySQL 中创建一张表 3 创建一个基于 Maven 的 JavaWeb 工程 4 编写 User 实体类 5 创建 Mybatis 全局配置文件 6 编写一个 DAO 或 Mapper 接口 7 编写 SQL 映射配置文件&#…

C++的继承和多态

继承和多态 继承继承的权限继承的子父类访问派生类的默认成员函数菱形继承(C独有)【了解】虚拟继承什么是菱形继承?菱形继承的问题是什么?什么是菱形虚拟继承?如何解决数据冗余和二义性的继承和组合的区别?…

Vue3如何使用Pinia状态管理库与持久化

大家好,我是你们的好朋友咕噜铁蛋!今天我将和大家分享如何在Vue3中使用Pinia状态管理库以及实现状态持久化的方法。作为一个Vue开发者,我们知道状态管理在大型应用程序中起着至关重要的作用。而Pinia作为Vue3推荐的状态管理库之一&#xff0c…

【论文笔记】Attention Is All You Need

【论文笔记】Attention Is All You Need 文章目录 【论文笔记】Attention Is All You NeedAbstract1 Introduction2 Background补充知识:软注意力 soft attention 和硬注意力 hard attention?补充知识:加法注意力机制和点乘注意力机制Extende…

HCIA-Datacom实验指导手册:6 构建基础 WLAN 网络

HCIA-Datacom实验指导手册:6 构建基础 WLAN 网络 一、实验介绍:二、实验拓扑:三、实验目的:四、配置步骤:1.掌握ap上线的配置方式和上线过程。ac配置验证 步骤 2 掌握隧道模式和旁挂模式下ac的配置。步骤 3 掌握查看ap…

android高级面试题2020,这套Github上40K+star面试笔记

前言 这里整理的是一些与技术没有直接关系的面试题,但是能够考察你的综合水平,所以不要以为不是技术问题,就不看,往往有时候就是这样一些细节的题目被忽视,而错过了一次次面试机会。 想要成为一名优秀的Android开发&…

生成服从伽马分布的随机样本np.random.gamma()

【小白从小学Python、C、Java】 【计算机等考500强证书考研】 【Python-数据分析】 生成服从伽马分布的随机样本 np.random.gamma() 选择题 关于以下代码输出的结果说法正确的是? import numpy as np import seaborn as sns a np.random.gamma(shape2,scale1.0,si…

WordPress通过宝塔面板的入门安装教程【保姆级】

WordPress安装教程【保姆级】【宝塔面板】 前言一:安装环境二:提前准备三:域名解析四:开始安装五:安装成功 前言 此教程适合新手,即使不懂代码,也可轻松安装wordpress 一:安装环…

时间管理大师速成(程序员版)

01 时间管理的重要性 管理时间有几个主要的原因: 时间和生活质量:时间是我们拥有的最宝贵的资源之一,管理好时间会直接影响我们的生活质量。高效的时间管理可以让我们开展日常活动,实现目标,并拥有休闲和休息的时间。 …
最新文章