- Java锁的逻辑(结合对象头和ObjectMonitor)
- 还在用饼状图?来瞧瞧这些炫酷的百分比可视化新图形(附代码实现)⛵
- 自动注册实体类到EntityFrameworkCore上下文,并适配ABP及ABPVNext
- 基于Sklearn机器学习代码实战
ntpdate:只能同步一次时间 。
ntp:持久同步时间 。
chrony:持久同步时间,精度比上面的ntp更好,速度更快.
格式:ntpdate host
root@ubuntu1804:~# apt install ntpdate
root@ubuntu1804:~# date
Tue Dec 13 15:12:07 CST 2022
root@ubuntu1804:~# date -d '-1 day'
Mon Dec 12 15:12:22 CST 2022
root@ubuntu1804:~# ntpdate ntp.aliyun.com
13 Dec 15:12:36 ntpdate[15040]: adjust time server 203.107.6.88 offset 0.002588 sec
root@ubuntu1804:~# date
Tue Dec 13 15:12:40 CST 2022 #同步后的时间
#安装ntp工具
root@ubuntu1804:~# sudo apt install apt -y
#将本机时间设置为两天前,便于后面测试
root@ubuntu1804:~# date -d '-2 day'
Sun Dec 11 15:15:51 CST 2022
#修改配置文件
root@ubuntu1804:~# vim /etc/ntp.conf
pool ntp.aliyun.com #指定时间服务器是阿里云的时间服务器
#重启服务
root@ubuntu1804:~# systemctl restart ntp.service
#查看同步情况
root@ubuntu1804:~# date
Tue Dec 13 15:16:56 CST 2022
#查看同步的过程
root@ubuntu1804:~# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
ntp.aliyun.com .POOL. 16 p - 64 0 0.000 0.000 0.000
ntp.ubuntu.com .POOL. 16 p - 64 0 0.000 0.000 0.000
203.107.6.88 10.137.55.181 2 u 49 64 1 49.907 11.370 0.000
91.189.91.157 ( 194.58.200.20 2 u 47 64 1 249.332 6.425 0.000
185.125.190.57 167.28.20.25 2 u 58 64 1 290.552 21.957 0.000
185.125.190.58 167.28.20.25 2 u 60 64 1 284.391 27.227 0.000
pugot.canonical 17.253.34.253 2 u 60 64 1 275.512 31.489 0.000
#参数说明
remote: 表示NTP主机的IP或者是主机名,最左边的
refid: 表示参考的上一层NTP主机的地址;
st: 表示的含义是startnum,一般范围是从0-->15;
when: 表示几秒前做过时间同步化更新操作;
poll: 表示下一次更新在几秒钟之后;
reach: 表示已经向上一层服务器要求更新的次数;
delay: 表示数据在传输过程中延迟的时间;
offset: 是源时钟与本地时钟的时间差(毫秒)。
jitter: Linux系统时间和BIOS硬件时间的差异;
chrony会监听udp的两个端口,如果是作为客户端,就监听udp的323端口,如果是服务端就监听123端口.
# 安装服务
root@ubuntu1804:~# apt install chrony
#修改配置文件
root@ubuntu1804:~# vim /etc/chrony/chrony.conf
pool ntp.aliyun.com
#将时间设置错,便于测试
root@ubuntu1804:~# date -s '20211010'
Sun Oct 10 00:00:00 CST 2021
#启动服务
root@ubuntu1804:~# systemctl start chrony
#查看有多少个ntp源在线:
root@ubuntu1804:~# chronyc activity
200 OK
5 sources online
0 sources offline
0 sources doing burst (return to online)
0 sources doing burst (return to offline)
0 sources with unknown address
#显示本机时间和远程服务器同步的情况
root@ubuntu1804:~# chronyc sources
210 Number of sources = 5
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^+ prod-ntp-3.ntp1.ps5.cano> 2 6 17 16 -4318us[-2258us] +/- 136ms
^- pugot.canonical.com 2 6 27 12 -3890us[-3890us] +/- 163ms
^+ alphyn.canonical.com 2 6 17 16 +18ms[ +20ms] +/- 176ms
^* prod-ntp-5.ntp4.ps5.cano> 2 6 17 15 -6154us[-4094us] +/- 138ms
^? 203.107.6.88 2 6 1 23 +13ms[-10312h] +/- 33ms
root@ubuntu1804:~# date
Tue Dec 13 15:36:54 CST 2022
#等待几分钟,时间恢复正常
root@ubuntu1804:~# date
Tue Dec 13 15:36:54 CST 2022
通过将一台主机搭建为时间服务器,其它局域网内的主机可以和本机的时间进行同步.
#只需要再ntp的配置文件中指定允许谁和本机进行同步就行。
#修改配置文件
root@ubuntu1804:~# vim /etc/ntp.conf
server 127.0.0.1 #以本机的时间为准
restrict default #表示允许所有主机与本机进行ntp同步
# restrict 10.0.0.0 mask 255.255.255.0 #允许这个网段的主机与本机进行ntp同步
#启动服务
root@ubuntu1804:~# systemctl restart ntp
# 客户机测试;
root@ubuntu1804:/etc/nginx/conf.d# ntpdate 10.0.0.44
13 Dec 15:57:09 ntpdate[3364]: adjust time server 10.0.0.44 offset 0.028476 sec
# chrony默认是作为客户端使用的,要想使用服务端的功能,就需要打开123这个端口
# 将chrony配置为服务端的方法:allow指令
# allow 0.0.0.0/0 表示的是任何主机都可以和本机进行时间的同步
#安装chrony
root@ubuntu1804:~# apt install chrony -y
#修改改配置文件
root@ubuntu1804:~# vim /etc/chrony/chrony.conf
server 127.0.0.1 #以本地的时间为准
local stratum 10 #互联网无法连接,仍然可提供时间同步服务 # 将当前服务器设置为第十层(把自己设置为内部服务器的意思)
allow 0.0.0.0/0 #指定允许同步的网段
#重启服务
root@ubuntu1804:~# systemctl restart chronyd
#修改一个本地时间
root@ubuntu1804:~# date -s '20221010'
Mon Oct 10 00:00:00 CST 2022
#客户端测试
root@ubuntu1804:/etc/nginx/conf.d# ntpdate 10.0.0.44
10 Oct 00:00:18 ntpdate[3410]: step time server 10.0.0.44 offset -5588217.989475 sec
#时间同步为和服务端一样了
root@ubuntu1804:/etc/nginx/conf.d# date
Tue Dec 13 16:17:22 CST 2022
说明:
(1)ntp和chrony是客户端和服务端一体的工具,通过不同的设置配置为客户端或者服务端.
(2)server和pool指定的区别:
server #用于指定单个NTP服务器,iburst:让同步时间的时候更快,开启多个并行任务来进行同步
pool #用于指定NTP服务器池而不是单个NTP服务器。池名称应解析为随时间可能会变化的多个地址
(3)配置为客户端时,指定时间服务器的相关参数; 。
server 192.168.7.49 prefer iburst # prefer表示如果指定了多个时间服务器的情况下优先用这个 iburst:表示加速时间同步
https://zhuanlan.zhihu.com/p/451555297 。
最后此篇关于LinuxNTP工具的基本使用的文章就讲到这里了,如果你想了解更多关于LinuxNTP工具的基本使用的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
这个问题在这里已经有了答案: Android ADT version required 20.0.0 and above (10 个答案) 关闭 9 年前。 我刚刚安装了 Eclipse Juno
按照 This page from codeplex 上的指南进行操作后,我无法在我的工具/选项窗口中看到 Python 选项。我认为我与指南的唯一偏差是: 发行版:没有安装 activestate
我有一个非常大的 .sql 脚本。我将此脚本添加到 Visual Studio 2013 下的 SQL Server 项目中。当我尝试构建它时,我收到此错误消息 This T-SQL script e
当我在SpringBoot项目中想加个依赖,但是不确定现有依赖的依赖的依赖.....有没有添加过这个依赖,怎么办呢?如果添加过了但是不知道我需要的这个依赖属于哪个依赖的下面,怎么查呢? IDEA中提供
我正在做一个项目来减少 PDF 的大小,压缩它们。我想知道市场上是否有任何非常好的工具/库(.NET)。 我确实尝试了一些像 Onstream Compression 这样的工具,但结果并不令人满意。
我想从我的源代码编译一个安卓内核。 但我想使用工具或类似的东西。 所以我只需单击一个按钮并获得一个可闪存的 zip 文件... 有工具吗? 我可以用脚本来做吗? 谢谢! 最佳答案 这取决于您从哪里获得
我们生成 pdf 文件,其中包含有关数万名客户每月财务余额的数据。在高峰期(年底有 100.000 个文件),使用在 5 台服务器之间分配负载,该过程可能需要长达 5 天的时间才能完成。工作负载的分配
模块:xmllib xmllib 是一个非验证的低级语法分析器。应用程序员使用的 xmllib 可以覆盖 XMLParser 类,并提供处理文档元素(如特定或类属标记,或字符实体)的方法。从 Py
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 3 年前。
我在一家医疗保健公司工作,拥有有关患者位置(地址、城市、州、 zip )的信息。我试图确定有多少百分比的患者住在离 5 个特定位置最近的地方。我正在寻找的答案是“25% 的患者住在离#1 地点最近的地
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 4年前关闭。 我们不允许在 Stack Overflow 上提出有关通用计算硬件和软件的问题。您可以编辑问
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be
请问我在哪里可以得到 SvcTraceViewer 工具? 我尝试下载并安装许多 SDK。 我查看了程序文件的垃圾箱。 我需要它来跟踪我的 WCF 调用出了什么问题。 最佳答案 您可以通过下载 Win
我正在尝试在我最喜欢的编辑器中设置适当的代码完成功能,我们将其称为AnEditor,以避免互联网上充斥着特定于程序的答案。 (您知道语言是ALanguage。)编辑器具有两个我喜欢的功能:它既可以在控
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
当 merge 的两个分支对同一文件有更改时,Mercurial 是否总是使用外部 merge 工具? 或者它是否首先查看它是否可以 merge 文件本身,如果不能,则仅转向外部工具? 我问的原因是我
我正在为我使用的编辑器编写 Scala 插件,该插件将突出显示所有未使用的代码路径(可能未使用 defs 、 vals 、 classes 和 implicits ),并为用户提供一个选项以将它们从.
我有 jquery 工具滚动器...我喜欢它只为 swipeLeft swipeRight 实现触摸选项。 当我使用 touch: true 时,它也会在向上/向下滑动时旋转.. 我按照此处的说明
我已经尝试了一些用于构建 UML(对象/依赖图)的 Eclipse 工具,但我真正需要的是一个工具来生成这样的代码外 UML。 (反之亦然) 我更喜欢一个简单的 UML 工具,它易于安装并且没有任何依
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
我是一名优秀的程序员,十分优秀!