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.orgrestrict 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.
#cryptoincludefile /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.
#cryptoincludefile /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.hqwc.cn/news/499247.html

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

相关文章

MATLAB环境下使用相关图可视化相关矩阵

为了处理各行各业中出现的高维数据,迫切需要寻找适用的统计学方法。大维随机矩阵理论是处理高维数据的理论工具之一,在高维统计分析中,表现出良好的性能并有着广泛的应用。 二十世纪四十年代和五十年代初期,大维随机矩阵理论起源…

前端,测试,后端,该如何选择?

前端开发,测试,后端,该如何选择?说实话,只要对互联网行业有了解的,都会推荐你学测试。 首先必须声明,能在前端开发、测试、后端(主要是Java)这三个岗位中进行选择&#…

【Intel oneAPI实战】使用英特尔套件解决杂草-农作物检测分类的视觉问题

目录 一、简介:计算机视觉挑战——检测并清除杂草二、基于YOLO的杂草-农作物检测分类2.1、YOLO简介2.2、基于YOLO的杂草-农作物检测分类解决方案 三、基于YOLO的杂草-农作物检测分类系统设计3.1、基于flask框架的demo应用程序后端3.2、基于Vue框架的demo应用程序前端…

Unity 使用脚本获取组件,代码生成预制体

代码获取组件 using System; using System.Collections; using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine;// 必须要继承 MonoBehaviour 才是一个组件 // 类名必要与文件名一致public class c1 : MonoBehaviour {// 使用 public 初始变量时…

day09_面向对象_构造方法_封装

今日内容 零、 复习昨日 一、构造方法 二、重载 三、封装 零、 复习昨日 1 类和对象是什么关系? 类是模板(原材料)对象是具体实例(成品)类创建出对象 2 类中有什么?(类的成员) 成员属性(成员变量), 成员方法 3 创建对象的语法? 类名 对象名 new 类名(); 4 调用对象属性,方法…

Go开发 入门以VSCode为例

一、Go环境搭建 1.1 安装 进入Golang官网 https://go.dev,点击 Download 若无法打开网页可以使用国内的Go语言中文网 https://studygolang.com/dl 进入下载 找到合适的平台点击链接下载即可(这里以Windows距离) 下载完成后 Next Next 安…

js 对象总结

文章目录 1、创建对象的6种方式总结一、new 操作符 Object 创建对象二、字面式创建对象 2、js 如何判断对象是否为空3、获取对象长度4、js 遍历对象的 5 种方法1、for … in2、Object.keys(obj)3、Object.values(obj)4、Object.getOwnPropertyNames(obj)5、使用Reflect.ownKey…

C# OpenVINO Nail Seg 指甲分割 指甲检测

目录 效果 模型信息 项目 代码 数据集 下载 C# OpenVINO Nail Seg 指甲分割 指甲检测 效果 模型信息 Model Properties ------------------------- date:2024-02-29T16:41:28.273760 author:Ultralytics task:segment version&#…

VirtualBox虚拟机安装 Linux 系统

要想学习各种计算机技术,自然离不开Linux系统。并且目前大多数生产系统都是安装在Linux系统上。常用的Linux系统有 Redhat,Centos,OracleLinux 三种。 三者的区别简单说明如下: Red Hat Enterprise Linux (RHEL): RHEL 是由美国…

InnoDB锁介绍

本文主要介绍MySQL InnoDB引擎中的各种锁策略和锁类别,并针对记录锁做演示以便于理解。 以下内容适用于MySQL 8.0版本。 读写锁 处理并发读/写访问的系统通常实现一个由两种锁类型组成的锁系统。这两种锁通常被称为共享锁(shared lock)和排他锁(exclusive lock)&…

如何在Window系统部署BUG管理软件并结合内网穿透实现远程管理本地BUG

文章目录 前言1. 本地安装配置BUG管理系统2. 内网穿透2.1 安装cpolar内网穿透2.2 创建隧道映射本地服务3. 测试公网远程访问4. 配置固定二级子域名4.1 保留一个二级子域名5.1 配置二级子域名6. 使用固定二级子域名远程 前言 BUG管理软件,作为软件测试工程师的必备工具之一。在…

【数据分享】2001-2022年我国省市县镇四级的逐日平均降水量数据(免费获取\excel\shp格式)

降水数据是我们在各项研究中最常用的气象指标之一!之前我们给大家分享过来源于国家青藏高原科学数据中心发布的1961—2022年全国范围的逐日降水栅格数据(可查看之前的文章获悉详情)! 本次我们分享的是2001-2002年我国省市县镇四个…