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 ...
随机推荐
- Golang爬虫:使用正则表达式解析HTML
之前所写的爬虫都是基于Python,而用Go语言实现的爬虫具有更高的性能. 第一个爬虫 使用http库,发起http请求 package main import ( "fmt" & ...
- 如何借助分布式存储 JuiceFS 加速 AI 模型训练
传统的机器学习模型,数据集比较小,模型的算法也比较简单,使用单机存储,或者本地硬盘就足够了,像 JuiceFS 这样的分布式存储并不是必需品. 随着近几年深度学习的蓬勃发展,越来越多的团队开始遇到了单 ...
- NC17383 A Simple Problem with Integers
题目链接 题目 题目描述 You have N integers A1, A2, ... , AN. You are asked to write a program to receive and e ...
- 你知道Object类和Objects的常用方法吗
文章目录 Object的常用方法 Objects的常用方法 hashCode hash isNull equals requireNonNull compare nonNull 大家好,Leo又来了! ...
- 利用css var函数让你的组件样式输出规范样式API,可定制性更高;
我们平时在使用Elementui Antdesing这些UI库时,难免会碰到使用deep强行侵入式去修改组件内部样式的情况: 比如下列代码,我们需要把ant的分页样式进行高度自定义,就得使用dee ...
- 音视频八股文(9)-- flv的h264六层结构和aac六层结构
flv介绍 FLV(Flash Video)是Adobe公司推出的⼀种流媒体格式,由于其封装后的⾳视频⽂件体积⼩.封装简单等特点,⾮常适合于互联⽹上使⽤.⽬前主流的视频⽹站基本都⽀持FLV.采⽤FLV ...
- 2022-02-01:粉刷房子 II。 假如有一排房子,共 n 个,每个房子可以被粉刷成 k 种颜色中的一种,你需要粉刷所有的房子并且使其相邻的两个房子颜色不能相同。 当然,因为市场上不同颜色油漆的价
2022-02-01:粉刷房子 II. 假如有一排房子,共 n 个,每个房子可以被粉刷成 k 种颜色中的一种,你需要粉刷所有的房子并且使其相邻的两个房子颜色不能相同. 当然,因为市场上不同颜色油漆的价 ...
- npm安装报错
npm ERR! request to https://registry.cnpmjs.org/element-ui failed, reason: Hostname/IP does not matc ...
- phpstudy-pikachu-字符型注入(get)
在查询栏输入1,点击查询获得查询格式 ?name=1'&submit=查询 *捷径 ' or 1=1 --+ *非捷径 ?name=1' and 1=2 --+ 2--+&submit ...
- npm run serve/build 背后的真实操作
vue CLI 用起来的确很舒服,方便省事,但他经过层层封装很难明白,执行完那个npm run serve/build 后他都干了些什么,甚至不知道整个项目是怎么跑起来的,今天自己抽时间就去瞅瞅,为加 ...