Linux服务器ntp时间同步离线安装配置

Linuk离线安装安装ntp服务和ntpdate 阅读详情


写在前面:在大多数实际生产环境集群模式中,需要进行配置集群中所有服务器时间同步,避免因时间不同步导致集群异常问题;但是大多数公司生产环境都为内网环境不能连接互联网进行在线安装ntp服务,本文基于内网环境进行ntp服务安装配置,做到内网集群时间自动同步。

1.环境准备

准备三台(或三台以上)物理机或虚拟机,选择其中一台作为NTP服务端,其他作为NTP客户端。

IP主机名角色
192.168.86.201esnode1NTP服务端
192.168.86.202esnode2NTP客户端
192.168.86.203esnode3NTP客户端

2.下载安装包

确认操作系统版本,可执行以下命令确认自己系统的版本信息(我的Linux系统为CentOS7.4 x86_64版本)

cat /etc/redhat-release
uname -a
cat /proc/version

确认系统版本截图
确认系统是否已安装NTP服务

rpm -qa | grep ntp

在这里插入图片描述
注:我的系统通过在线安装已经安装过,这里为了演示离线安装我进行卸载。

如果系统自带或已安装版本不符合个人需求,可进行卸载,命令如下:

rpm -e --nodeps ntpdate-4.2.6p5-29.el7.centos.2.x86_64
rpm -e --nodeps ntp-4.2.6p5-29.el7.centos.2.x86_64

在这里插入图片描述

离线安装NTP需要下载NTP相关rpm安装包
可以通过https://pkgs.org/download/ntp查找所需对应操作系统的安装包
需要下载ntp与ntpdate两个安装包

ntp下载截图
也可以直接通过以下链接进行下载:

http://mirror.centos.org/centos/7/updates/x86_64/Packages/ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm
http://mirror.centos.org/centos/7/updates/x86_64/Packages/ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm

3.安装NTP服务

下载完成所需安装包,接下来就进行NTP服务的安装
安装ntpdate

rpm -ivh ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm

在这里插入图片描述
安装ntp

rpm -ivh ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm

在这里插入图片描述
温馨提示:其他节点参考此步骤进行安装。

4.配置NTP

NTP服务器端配置

vim /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
# 允许192.168.86.0网段内所有机器从esnode1同步时间
restrict 192.168.86.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客户端配置

# 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

# 从esnode1中同步时间
server 192.168.86.201

# 允许esnode1修改本地时间
restrict 192.168.86.201 nomodify notrap noquery

# 如果esnode1不可用,用本地的时间服务
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

5.验证时间同步

启动ntp服务器需要在各节点先手动同步一下时间
如果能连接互联网且在ntp服务端配置了上层服务端为中国国家授时中心服务器地址,应先手动同步一下国家授时中心时间,命令如下:

ntpdate cn.pool.ntp.org

其他客户端节点都进行手动同步ntp服务端时间,命令如下:

ntpdate 192.168.86.201

启动ntp

systemctl start ntpd.service

查看启动运行状态

systemctl status ntpd.service

在这里插入图片描述

ntpstat

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
每个节点开启开机自启动

systemctl enable ntpdate.service
或
chkconfig ntpd on

同时执性date命令

[root@esnode1 ~]# date
Thu Sep 10 11:00:55 CST 2020
[root@esnode2 ~]# date
Thu Sep 10 11:00:55 CST 2020
[root@esnode3 ~]# date
Thu Sep 10 11:00:55 CST 2020

结语:如若文章有何不妥之处欢迎指正,谢谢!

linux下ntp服务器安装包,Linux彻底离线RPM安装NTP(时间同步)服务器及基本配置 RHEL彻底离线安装NTP服务器内网环境安装NTP服务,通常有2种方式。一、若是没有现成的时间同步服务器。一台主机A作为NTP服务器,其它主机B只安装ntpdate服务,B主机们经过ntpdate命令同步主机A的时间。二、有现成的时间同步服务器。全部主机直接经过ntpdate命令,同步时间服务器的时间。这里主要介绍的是第一种方式一、下载合适的NTP安装包(RPM)查询主机Linux系统版本web#... 阅读详情

相关推荐

2024年Linux最全Linux完全离线RPM安装NTP(时间同步)服务器及基本配置

最近很多小伙伴找我要Linux学习资料,于是我翻箱倒柜,整理了一些优质资源,涵盖视频、电子书、PPT等共享给大家!

2401_83947105的博客 3172

Linux离线安装NTP服务,无外网环境下配置本地时间同步

1、常用命令 rpm -qa | grep ntp #查询已安装的ntp版本信息等 rpm -e --nodeps ntp-4.2.6p5-29.el7.centos.2.x86_64 #卸载 systemctl status ntpd #查询ntp服务状态 systemctl start ntpd #启动 systemctl stop ntpd #停止 systemctl restart ntpd #重启 ntpq -p #查看ntp服务器与上层ntp的状态

DraGon_HooRay的博客 1万+

2024年Linux完全离线RPM安装NTP(时间同步)服务器及基本配置(2),面试字节跳动的Linux运维工程师该怎么准备

查询是否安装NTP服务我们系统为RHEL 6.5 x86_64(红帽企业版),一定要。(几乎涵盖了所有RPM包)

2401_83621004的博客 515

Linux完全离线RPM安装NTP(时间同步)服务器及基本配置

RHEL完全离线安装NTP服务器 内网环境安装NTP服务,一般有2种方式。 1、如果没有现成的时间同步服务器。一台主机A做为NTP服务器,其它主机B只安装ntpdate服务,B主机们通过ntpdate命令同步主机A的时间。 2、有现成的时间同步服务器。所有主机直接通过ntpdate命令,同步时间服务器的时间。 这里主要介绍的是第一种方式 1、下载合适的NTP安装包(RPM) 查询主机Linu...

ajiong的博客 2万+

2024年最全Linux完全离线RPM安装NTP(时间同步)服务器及基本配置,2024年最新做了6年Linux运维开发

最全的Linux教程,Linux从入门到精通第一份《Linux从入门到精通》466页内容简介====本书是获得了很多读者好评的Linux经典畅销书**《Linux从入门到精通》的第2版**。本书第1版出版后曾经多次印刷,并被51CTO读书频道评为“最受读者喜爱的原创IT技术图书奖”。本书第﹖版以最新的Ubuntu 12.04为版本,循序渐进地向读者介绍了Linux 的基础应用、系统管理、网络应用、娱乐和办公、程序开发、服务器配置、系统安全等。本书附带1张光盘,内容为本书配套多媒体教学视频。

m0_60607971的博客 515

Ubuntu服务器离线部署NTP服务全攻略:从下载到配置避坑指南

本文详细介绍了在Ubuntu服务器上离线部署NTP时间同步服务的完整流程与避坑指南。内容涵盖从精准获取离线安装包、处理服务冲突,到服务端与客户端的深度配置、安全加固及分层架构构建。重点解决了离线环境下依赖管理、配置优化和常见故障排查等核心挑战,为内网环境提供可靠的时间同步解决方案。

w1x2y3的博客 215

使用rpm包升级ntpd服务_Linux完全离线RPM安装NTP(时间同步)服务器及基本配置【NTP时间同步服务器】...

查询主机Linux系统版本查询是否安装NTP服务我们系统为RHEL 6.5 x86_64(红帽企业版),一定要根据系统版本寻找合适的RPM安装包。RPM下载网站:http://pkgs.org/download/ntp(几乎涵盖了所有RPM包)ntpdate-4.2.6p5-12.el6.centos.2.x86_64.rpm如果只需要实现第二种方案,则只需要下载该安装包ntp-4.2.6p5-1...

weixin_34643336的博客 1034

【Linux】Linux Centos 7.6 离线RPM安装NTP(时间同步)服务器及基本配置

一个环境,因为需要需要ntp时间同步服务RHEL完全离线安装NTP服务器内网环境安装NTP服务,一般有2种方式。如果没有现成的时间同步服务器。一台主机A做为NTP服务器,其它主机B只安装ntpdate服务,B主机们通过ntpdate命令同步主机A的时间。有现成的时间同步服务器。所有主机直接通过ntpdate命令,同步时间服务器的时间。这里主要介绍的是第一种方式。

九师兄 1402

Linux离线安装NTP服务指南

Linux离线安装NTP服务指南 去发现同类优质开源项目:https://gitcode.com/ 在此仓库中,我们提供了详细的步骤和指南,帮助您在内网环境下配置Linux服务器的本地时间同步。通过这份资源文件,您可以轻松地在多台服务器上安装NTP服务。 资源文件简介 该资源文件涵盖了以下关键内容: 离线安装NTP服务的具体步骤。 如何在内网环境下配置NTP以实现本地时间同步。 常用NTP服务的...

gitblog_06720的博客 542

Linux离线环境下NTP服务安装及配置

本文还有配套的精品资源,点击获取 简介:在Linux系统中,时间同步是维持系统稳定性与安全性的重要因素。NTP协议广泛用于网络时间同步。本文档提供了适用于CentOS 6的NTP及其组件的RPM安装包,适用于无网络连接的离线安装。包内包含NTP服务器主包、ntpdate工具、字体文件系统组件以及安装文档。文章详细介绍了NTP服务的离线安装步骤,包括依赖安装、服务安装、配置及...

weixin_42174098的博客 3030

ntp离线安装包

用于多个服务器之间的时间同步问题,保证多台服务器的时间是一致的。

在Linux内网安装NTP,配置时钟同步

1、NTP服务安装 2、配置 NTP时间同步源 3、定时同步

weixin_45324716的博客 4021

Linux离线安装NTP服务,内网环境下配置本地时间同步

Linux离线安装NTP服务,内网环境下配置本地时间同步 多台服务器安装 1、常用命令 rpm -qa | grep ntp #查询已安装的ntp版本信息等 rpm -e --nodeps ntp-4.2.6p5-29.el7.centos.2.x86_64 #卸载 systemctl status ntpd #查询ntp服务状态 systemctl start ntpd #启动 systemctl stop ntpd #停止 systemctl restart ntpd #重启 ntpq -p #查看ntp服务器与上层ntp的状态 ntpstat #查看时间同步状态(查看ntp服务器有无和上层ntp连通),这个一般需要5-10分钟后才能成功连接和同步。所以,服务器启动后需要稍等下。

离线NTP服务器搭建(Linux)

离线NTP服务器搭建(Linux) 实例: 服务端-192.168.111.143 客户端-192.168.111.170 1. 获取rpm包 解压操作系统的镜像文件,获取rpm包 .\CentOS-7.4-x86_64-DVD-1708\Packages 2. 安装rpm rpm -ivh autogen-libopts-5.18-5.el7.x86_64.rpm rpm -ivh ntpdate-4.2.6p5-25.el7.centos.2.x86_64.rpm rpm -ivh ntp-4.2.6p

weixin_43879330的博客 729

搭建NTP服务器所需要的离线安装包

搭建NTP服务器所需要的离线安装包,使用方式 #安装ntp服务器以及其依赖包 rpm -ivh autogen-libopts-5.18-5.el7.x86_64.rpm rpm -ivh ntp-4.2.6p5-18.el7.centos.x86_64.rpm rpm -ivh ntpdate-4.2.6p5-18.el7.centos.x86_64.rpm #启动ntp服务并设置开机启动 systemctl start ntpd systemctl enable ntpd

自定义串口通讯协议

自定义串口通讯协议的实现方法

qq_44826038的博客 2172

centos7 ntp服务安装

使用date命令检测最终时间与网络时间一致,配置完成。修改/etc/ntp.conf ,后续操作参考。使用yum命令安装,失败,内网环境。#发现服务器时间不对。

weixin_43082983的博客 530

腾讯会议录屏损坏修复:使用 recover_mp4 工具的完整解决方案

腾讯会议录屏损坏修复指南 当腾讯会议录屏因电脑蓝屏等意外导致MP4文件损坏时,可使用recover_mp4工具结合FFMPEG进行修复。操作步骤包括:1)准备相同参数正常视频作为参考;2)分析正常视频生成结构文件;3)分离损坏视频的音视频流;4)使用FFMPEG重新封装。该方法能有效修复因意外中断导致的视频索引损坏问题。修复前需将工具和文件放在同一目录下,并确保参考视频与损坏录屏的参数完全一致。

m0_62498496的博客 2627

linux服务器设置时间同步(ntp的设置)

设置服务器时间同步校验的方法

健康平安的活着的专栏 4502

【ROS2】机械臂MoveIt2

navigation2 专注于移动机器人的导航与定位,处理大范围空间的底盘运动;MoveIt2 专注于机械臂的操作规划,处理多关节协同的末端执行器运动。在复合机器人(如,移动机械臂)navigation2 负责移动到目标区域,MoveIt2 负责机械臂抓取。官网:https://moveit.picknik.ai/main/index.html。

郭老二 597

SAP Fiori Elements 扩展实战:UI 层扩展、OData 服务扩展、CDS 视图增强及全流程案例

UI 层扩展主要关注在不修改标准生成界面的基础上,自定义用户界面元素和交互逻辑。典型需求包括:在现有 Fiori Elements 界面上添加新的字段(如表格列或表单项)、增加自定义按钮并绑定操作、以及通过控制器扩展加入事件处理等。无论在 RAP 还是传统 BOPF 架构下,前端 UI 扩展通常采用 SAPUI5 提供的**扩展点(Extension Points)和控制器扩展(Controller Extension)**机制来安全地插入自定义代码。下面分别说明两种后端架构下 UI 扩展的实现方式。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 902

Linux时间同步利器:Chrony命令详解与应用实践

本文全面介绍了Chrony时间同步工具的核心优势及实践应用。作为传统NTP的替代方案,Chrony凭借快速收敛、高精度和强适应性(精度可达微秒级)成为Linux系统时间管理的首选。文章详细讲解其安装配置(包括主配置文件解析)、高级功能(手动调整/动态监控/安全配置)以及典型应用场景(私有NTP服务器搭建/虚拟机优化/离线运行),并提供了故障排查与性能调优方案。通过合理配置,Chrony可满足金融、云计算等对时间敏感场景的需求,确保分布式系统时间一致性。

weixin_70208651的博客 1515

DevExpress中使用BandGridView实现复合(多行)表头、设置多行表头背景颜色、表格边框颜色

一、实现效果 二、 实现方法 2.1、创建复合表头 ①将创建的GridControl下的GirdView1转化为BandGridView类型; ②创建需要展示的列(指定列的名称【Name】、描述【caption】、数据字段名称【FieldName】) ③绑定列实现复合表头。 注意:如果复合表头有多行,则需要设置新增Band的Row Count,然后设置【Band properties下的AutoFillDown=false】 详细操作如下: 注意:如果要隐藏表格的设计字段内容,则需.

提供C#相关开发 、云计算、运维测试、网络安全相关技术分享与服务,有意向可联系。 2894
上一篇: Linux服务器间免密登录配置
下一篇: 问题解决-hive使用spark引擎执行SQL时,yarn报错:java.lang.NoClassDefFoundError: org/antlr/runtime/tree/CommonTree
software_student
博客等级 码龄12年 27粉丝 8原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值