Debian12配置NTP时间同步
环境
查看系统版本:lsb_release -a

配置NTP时间同步
下面的配置需要用到管理员权限,可以使用su切换到管理员权限。
查看/修正 时区
查看系统时区:timedatectl

如果时区不是Asia/Shanghai需要修改时区为东八区
root@debian:/home/test# timedatectl set-timezone "Asia/Shanghai"
查看本地时间
如果本地时间与NTP服务器时间误差太大(1000s以上),需要先手动校正本地系统时间,手动校正可以使用ntpdate命令强制修正本地时间
ntpdate NTPServerIP后面跟NTP服务器的IP地址,从这里
root@debian:/home/test# ntpdate -d ntp.ntsc.ac.cn
ntpdig: querying 114.118.7.163 (ntp.ntsc.ac.cn)
ntpdig: querying 114.118.7.161 (ntp.ntsc.ac.cn)
org t1: e86314a0.b6c0a000 rec t2: e8646973.584fce78
xmt t3: e8646973.58e812a7 dst t4: e86314a1.c05f7000
org t1: 1689818656.713877 rec t2: 1689905907.344968
xmt t3: 1689905907.347291 dst t4: 1689818657.751456
rec-org t21: 87250.631091 xmt-dst t34: 87249.595835
2023-07-21 10:18:27.347291 (+0800) +87250.113463 +/- 0.517644 ntp.ntsc.ac.cn 114.118.7.161 s1 no-leap
CLOCK: time stepped by 87250.113463
CLOCK: time changed from 2023-07-20 to 2023-07-21
root@debian:/home/test# date
2023年 07月 21日 星期五 10:18:44 CST
如果没有ntpdate命令,可以使用date -s "YYYY-MM-DD HH:MM:SS"手动修改本地时间
root@debian:/home/test# date -s "2023-7-20 10:00:00"
2023年 07月 20日 星期四 10:00:00 CST
配置NTP自动校时
编辑/etc/ntpsec/ntp.conf配置NTP服务器地址,将默认的pool配置注释掉(前面加#号代表注释),添加新的配置,下面是ntp.conf文件的所有配置
root@debian:/home/test# cat /etc/ntpsec/ntp.conf
# /etc/ntpsec/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntpsec/ntp.drift
leapfile /usr/share/zoneinfo/leap-seconds.list
# To enable Network Time Security support as a server, obtain a certificate
# (e.g. with Let's Encrypt), configure the paths below, and uncomment:
# nts cert CERT_FILE
# nts key KEY_FILE
# nts enable
# You must create /var/log/ntpsec (owned by ntpsec:ntpsec) to enable logging.
#statsdir /var/log/ntpsec/
#statistics loopstats peerstats clockstats
#filegen loopstats file loopstats type day enable
#filegen peerstats file peerstats type day enable
#filegen clockstats file clockstats type day enable
# This should be maxclock 7, but the pool entries count towards maxclock.
tos maxclock 11
# Comment this out if you have a refclock and want it to be able to discipline
# the clock by itself (e.g. if the system is not connected to the network).
tos minclock 4 minsane 3
# Specify one or more NTP servers.
# Public NTP servers supporting Network Time Security:
# server time.cloudflare.com nts
server 192.168.6.200 #添加NTP服务器地址
# pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will
# pick a different set every time it starts up. Please consider joining the
# pool: <https://www.pool.ntp.org/join.html>
#pool 0.debian.pool.ntp.org iburst #注释
#pool 1.debian.pool.ntp.org iburst #注释
#pool 2.debian.pool.ntp.org iburst #注释
#pool 3.debian.pool.ntp.org iburst #注释
# Access control configuration; see /usr/share/doc/ntpsec-doc/html/accopt.html
# for details.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.
# By default, exchange time with everybody, but don't allow configuration.
restrict default kod nomodify nopeer noquery limited
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

重启ntpd服务
service ntpd restart
查看同步状态:
ntpq -pn

等待系统识别并选择后,在IP前面会标*/+如下图所示

服务器主机名前符号的含义
-意味着本地NTP服务不太喜欢此服务器+表示本地 NTP 服务喜欢此服务器x标记错误的主机*指示当前收藏夹-
附:每列的含义
-
remote
- 远程 NTP 服务器的名称。如果使用 -n 开关,您将看到这些服务器的 IP 地址,而不是它们的主机名。
refid
- 指示每个服务器现在从何处获取时间。它可以是服务器主机名或类似 .全球定位系统。 ,表示全球定位系统源。
st
- tratum 是一个介于 1 到 16 之间的数字,表示远程服务器的精度。 1 表示最准确,16 表示“服务器无法访问”。您的层将等于精确的远程服务器加 1。切勿连接到第 1 层服务器,请使用第 2 层服务器!第 2 层服务器也适合我们的目的,此策略适用于减少第 1 层服务器的流量。
poll
时间请求之间的轮询间隔(以秒为单位)。该值的范围介于允许的最小和最大轮询值之间。最初,该值将较小,以便快速进行同步。时钟“同步”后,轮询值将增加,以减少网络流量和常用时间服务器上的负载。 reach
这是 8 位数组的八进制表示形式,表示本地计算机尝试到达服务器的最后 8 次。如果到达远程服务器,则设置该位。 delay
接收“现在几点了”请求的响应所需的时间(秒)。 offset
最重要的价值。本地服务器和远程服务器之间的时间差。在同步过程中,偏移时间降低,表明本地机器时间越来越准确。 jitter
离散(也称为抖动)是几个连续请求/响应对之间偏移的统计方差的度量。较低的色散值优于较高的色散值。较低的色散可实现更精确的时间同步。
ntpd服务加入开机启动
使用下面命令将ntpd服务加入开机启动
chkconfig --level 2345 ntpd on
end。
Debian12配置NTP时间同步的更多相关文章
- 如何在linux 上配置NTP 时间同步?
故障现象: 有些应用场景,对时间同步的要求严格,需要用到NTP同步,如何在linux上配置NTP时间同步? 解决方案: 在linux 上配置NTP 时间同步,具休操作步骤,整理如下: 1.安装软件包( ...
- Linux集群之间配置NTP时间同步ntp
NTP时间同步 注意事项 要注意的是,ntpd 有一个自我保护设置: 如果本机与上源时间相差太大, ntpd 不运行. 所以新设置的时间服务器一定要先 ntpdate 从上源取得时间初值, 然后启动 ...
- Linux集群配置ntp时间同步服务
集群中时间不同步有可能会让大数据的应用程序运行混乱,造成不可预知的问题,比如Hbase,当时间差别过大时就会挂掉,所以在大数据集群中,ntp服务,应该作为一种基础的服务,以下在演示在CentOS 7. ...
- 【转】Linux配置NTP时间同步服务器
分布式程序通常需要运行在一个统一的时间环境里. 转自:http://blog.csdn.net/mengfanzhundsc/article/details/62046562 安装NTP:yum in ...
- Centos 7配置ntp时间同步
1.NTP时钟同步方式说明 NTP在linux下有两种时钟同步方式,分别为直接同步和平滑同步: 1)直接同步 使用ntpdate命令进行同步,直接进行时间变更.如果服务器上存在一个1 ...
- Linux配置NTP时间同步
1.检查系统是否安装了NTP包(linux系统一般自带NTP4.2)没有安装我们直接使用yum命令在线安装:yum install ntp2.NTP服务端配置文件编辑vim /etc/ntp.conf ...
- yum仓库客户端搭建和NTP时间同步客户端配置
一.yum仓库客户端搭建 yum源仓库搭建分为服务器端和客户端. 服务端主要提供软件(rpm包)和yumlist.也就是提供yum源的位置.一般是通过http或者ftp提供位置. 客户端的配置:yum ...
- cloudstack安装篇3-SELinux配置、NTP时间同步、配置ClouStack软件库
一.SELinux配置 为了让CloudStack正常工作,我们必须将SELinux设置为permissive.需要在当前系统运行状态下和启动后都能够生效,进行以下配置. 在系统运行状态下的将SELi ...
- NTP时间同步 服务端 客户端 自动化安装配置
NTP时间同步 服务端 客户端 自动化安装配置 原创内容 http://www.cnblogs.com/elvi/p/7657994.html #!/bin/sh #运行环境 centos6.cent ...
- centos6.5安装配置NTP,集群各机器间时间同步
试验环境 提君博客原创 >>提君博客原创 http://www.cnblogs.com/tijun/ << IP 主机名 角色 描述 同步方式 192.168.11.11 ...
随机推荐
- springboot-poi ---封装注解式导入导出
此demo 是基于poi封装对象式注解导入导出,项目框架为springboot项目! 简单的说明一下此demo涉及到的知识点,希望能给初学者带来方便! poi-excel 基本操作(工具) 自定义注解 ...
- nginx启动报错80端口号已占用
开启或重启Nginx时报如下错误: Nginx [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) 原因是端口号80被其 ...
- 获取电脑的网络连接状态(五)WebClient
网络连接判断,使用WebClient测试获取: 1 public static bool IsWebClientConnected() 2 { 3 try 4 { 5 using (var clien ...
- Vue 前端开发团队风格指南(史上最全)
Vue官网的风格指南按照优先级(依次为必要.强烈推荐.推荐.谨慎使用)分类,本文根据项目实际情况整理了一份适用于团队开发的vue风格指南,供大家参考. 一.命名规范 常用的命名规范: camelCas ...
- 【自用】无限级分类获取SQL语句
自定义函数: 1 USE [ExpenseCenter_Fibrogen] 2 GO 3 /****** Object: UserDefinedFunction [dbo].[GetSubordina ...
- Mysql列转行, group_concat的使用
开始业务的查询的时候碰到一个sql的查询语句问题,主要是 group_concat 之前没用过,现在记录一下怎么用 group_concat 用法, 可以将相同的行组合起来 group_concat( ...
- 2022-10-17:特殊的二进制序列是具有以下两个性质的二进制序列: 0 的数量与 1 的数量相等。 二进制序列的每一个前缀码中 1 的数量要大于等于 0 的数量。 给定一个特殊的二进制序列 S,以
2022-10-17:特殊的二进制序列是具有以下两个性质的二进制序列: 0 的数量与 1 的数量相等. 二进制序列的每一个前缀码中 1 的数量要大于等于 0 的数量. 给定一个特殊的二进制序列 S,以 ...
- lec-6-Actor-Critic Algorithms
从PG→Policy evaluation 更多样本的均值+Causality+Baseline 减少variance 只要拟合估计Q.V:这需要两个网络 Value function fitting ...
- 第十三届蓝桥杯c++b组国赛题解(还在持续更新中...)
试题A:2022 解题思路: 有2022个物品,它们的编号分别是1到2022,它们的价值分别等于它们的编号.也就是说,有2022种物品,物品价值等于物品编号. 从2022个物品种选取10个物品,满足1 ...
- AcWing 1024. 装箱问题
有一个箱子容量为 V,同时有 n 个物品,每个物品有一个体积(正整数). 要求 n 个物品中,任取若干个装入箱内,使箱子的剩余空间为最小. 输入格式 第一行是一个整数 V,表示箱子容量. 第二行是一个 ...