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 ...
随机推荐
- .gitignore 文件语法介绍
.gitignore 文件的作用 A gitignore file specifies intentionally untracked files that Git should ignore. Fi ...
- 如何在 🤗 Space 上托管 Unity 游戏
你知道吗?Hugging Face Space 可以托管自己开发的 Unity 游戏!惊不惊喜,意不意外?来了解一下吧! Hugging Face Space 是一个能够以简单的方式来构建.托管和分享 ...
- vue【解决方案】页面/路由跳转后,滚动条消失,页面无法滚动
原因解析: vue项目中,页面/路由跳转后,body 的内联样式变成 overflow:hidden 解决方案: 使用路由守卫,在页面/路由跳转后,将body 的overflow设置为auto src ...
- 文心一言 VS chatgpt (7)-- 算法导论2.3 3~4题
三.使用数学归纳法证明:当n刚好是2的幂时,以下递归式的解是 T(n)=nlgn.若n=2,T(n)=2:若n=2^k,k>1,T(n)=2T(n/2)+n. 文心一言: chatgpt: 首先 ...
- 2021-11-04:计算右侧小于当前元素的个数。给你`一个整数数组 nums ,按要求返回一个新数组 counts 。数组 counts 有该性质: counts[i] 的值是 nums[i] 右
2021-11-04:计算右侧小于当前元素的个数.给你`一个整数数组 nums ,按要求返回一个新数组 counts .数组 counts 有该性质: counts[i] 的值是 nums[i] 右侧 ...
- 2021-09-09:企鹅厂活动发文化衫,文化衫有很多种,企鹅们都穿文化衫。采访中,企鹅会说还有多少企鹅跟他穿一种文化衫。有些企鹅没被采访到,将这些回答放在answers数组里,返回活动中企鹅的最少数
2021-09-09:企鹅厂活动发文化衫,文化衫有很多种,企鹅们都穿文化衫.采访中,企鹅会说还有多少企鹅跟他穿一种文化衫.有些企鹅没被采访到,将这些回答放在answers数组里,返回活动中企鹅的最少数 ...
- 「P2」试下1个半月能不能水出个毕设
0.目标 将上个 springboot 项目 + html 中的html用Vue来重写,也就是在原springboot项目中集成Vue 1.在界面上,将html改成vue的形式 1.1.原html & ...
- web自动化06-键盘操作
键盘操作 1.说明: 1). 模拟键盘上一些按键或者组合键的输入 如:Ctrl+C .Ctrl+V: 2). Selenium中把键盘的按键都封装在Keys类中 2. Keys类 导包:from se ...
- OODO有关账户account模块学习
一.记账凭证(Account Move) 会计上的记账凭证,也叫会计分录,在Odoo中叫"Account Move".Account Move直译是"账户移动" ...
- 非 root 用户手动编译安装 GCC
我们知道,关于 GCC 在 CentOS 下通过 yum 安装默认版本号,CentOS 5 是 4.1.2:CentOS 6 是 4.4.7:CentOS 7 是 4.8.3.很多时候在编译安装软件都 ...