参考文档:
https://www.tecmint.com/install-chrony-in-centos-ubuntu-linux/
https://www.redhat.com/sysadmin/chrony-time-services-linux
OS :Linux Mint21.1
oem@linuxmint:~$ cat /etc/os-release
NAME="Linux Mint"
VERSION="21.1 (Vera)"
ID=linuxmint
ID_LIKE="ubuntu debian"
PRETTY_NAME="Linux Mint 21.1"
VERSION_ID="21.1"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=vera
UBUNTU_CODENAME=jammy
oem@linuxmint:~$
-- 安装chrony ,使用命令apt install chrony .可以看到ntp包被卸载
oem@linuxmint:~$ apt install chrony
[sudo] password for oem:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成
下列软件包是自动安装的并且现在不需要了:
ibus-libpinyin liblua5.3-0 libmarisa0 libopencc-data libopencc1.1 libpinyin-data libpinyin13
使用'sudo apt autoremove'来卸载它(它们)。
下列软件包将被【卸载】:
ntp
下列【新】软件包将被安装:
chrony
升级了 0 个软件包,新安装了 1 个软件包,要卸载 1 个软件包,有 54 个软件包未被升级。
需要下载 290 kB 的归档。
解压缩后将会空出 1,485 kB 的空间。
您希望继续执行吗? [Y/n] y
获取:1 http://archive.ubuntu.com/ubuntu jammy/main amd64 chrony amd64 4.2-2ubuntu2 [290 kB]
已下载 290 kB,耗时 2秒 (168 kB/s)
(正在读取数据库 ... 系统当前共安装有 391254 个文件和目录。)
正在卸载 ntp (1:4.2.8p15+dfsg-1ubuntu2) ...
正在选中未选择的软件包 chrony。
(正在读取数据库 ... 系统当前共安装有 391201 个文件和目录。)
准备解压 .../chrony_4.2-2ubuntu2_amd64.deb ...
正在解压 chrony (4.2-2ubuntu2) ...
正在设置 chrony (4.2-2ubuntu2) ...
Creating config file /etc/chrony/chrony.conf with new version
Creating config file /etc/chrony/chrony.keys with new version
dpkg-statoverride: 警告: --update 已指定但 /var/log/chrony 不存在
Created symlink /etc/systemd/system/chronyd.service → /lib/systemd/system/chrony.service.
Created symlink /etc/systemd/system/multi-user.target.wants/chrony.service → /lib/systemd/system/chrony.service.
正在处理用于 man-db (2.10.2-1) 的触发器 ...
oem@linuxmint:~$
-- 查看chronyd服务的状态
em@linuxmint:~$ systemctl status chronyd
● chrony.service - chrony, an NTP client/server
Loaded: loaded (/lib/systemd/system/chrony.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-01-20 09:47:50 CST; 57min ago
Docs: man:chronyd(8)
man:chronyc(1)
man:chrony.conf(5)
Main PID: 12949 (chronyd)
Tasks: 2 (limit: 4561)
Memory: 1.3M
CPU: 619ms
CGroup: /system.slice/chrony.service
├─12949 /usr/sbin/chronyd -F 1
└─12950 /usr/sbin/chronyd -F 1
Jan 20 09:47:49 linuxmint systemd[1]: Starting chrony, an NTP client/server...
Jan 20 09:47:49 linuxmint chronyd[12949]: chronyd version 4.2 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH>
Jan 20 09:47:49 linuxmint chronyd[12949]: Initial frequency 3.904 ppm
Jan 20 09:47:50 linuxmint chronyd[12949]: Using right/UTC timezone to obtain leap second data
Jan 20 09:47:50 linuxmint chronyd[12949]: Loaded seccomp filter (level 1)
Jan 20 09:47:50 linuxmint systemd[1]: Started chrony, an NTP client/server.
Jan 20 09:47:56 linuxmint chronyd[12949]: Selected source 185.125.190.56 (ntp.ubuntu.com)
Jan 20 09:47:56 linuxmint chronyd[12949]: System clock TAI offset set to 37 seconds
Jan 20 09:47:56 linuxmint chronyd[12949]: Selected source 202.118.1.81 (2.ubuntu.pool.ntp.org)
Jan 20 09:49:02 linuxmint chronyd[12949]: Selected source 111.230.189.174 (0.ubuntu.pool.ntp.org)
lines 1-24/24 (END)
-- 配置chrony服务 ,把服务器地址添加上去
oem@linuxmint:~$ vi /etc/chrony/chrony.conf
-- 查看本机时间同步状态,用于验证服务是否已经启动
oem@linuxmint:~$ chronyc tracking
Reference ID : 6FE6BDAE (111.230.189.174)
Stratum : 3
Ref time (UTC) : Fri Jan 20 02:41:51 2023
System time : 0.000169761 seconds slow of NTP time
Last offset : -0.000193344 seconds
RMS offset : 0.001217608 seconds
Frequency : 3.569 ppm fast
Residual freq : -0.011 ppm
Skew : 0.792 ppm
Root delay : 0.015651939 seconds
Root dispersion : 0.008268453 seconds
Update interval : 512.1 seconds
Leap status : Normal
oem@linuxmint:~$
-- 查看时间同步服务器列表
oem@linuxmint:~$ chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^- prod-ntp-3.ntp1.ps5.cano> 2 9 377 855 -18ms[ -18ms] +/- 123ms
^- alphyn.canonical.com 2 9 377 79 +2796us[+2886us] +/- 167ms
^- pugot.canonical.com 2 9 377 83 -23ms[ -23ms] +/- 151ms
^- prod-ntp-5.ntp4.ps5.cano> 2 9 377 71 -20ms[ -20ms] +/- 127ms
^* 111.230.189.174 2 9 377 24 +2895us[+2985us] +/- 29ms
^- ntp8.flashdance.cx 2 9 327 12 -11ms[ -11ms] +/- 196ms
^- ntp1.ams1.nl.leaseweb.net 2 8 377 77 +34ms[ +34ms] +/- 220ms
^+ time.neu.edu.cn 1 9 377 86 +765us[ +855us] +/- 30ms
oem@linuxmint:~$
oem@linuxmint:~$ chronyc sources -v
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current best, '+' = combined, '-' = not combined,
| / 'x' = may be in error, '~' = too variable, '?' = unusable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^- prod-ntp-3.ntp4.ps5.cano> 2 9 377 1067 -18ms[ -18ms] +/- 123ms
^- alphyn.canonical.com 2 9 377 291 +2796us[+2886us] +/- 167ms
^- pugot.canonical.com 2 9 377 295 -23ms[ -23ms] +/- 151ms
^- prod-ntp-5.ntp4.ps5.cano> 2 9 377 283 -20ms[ -20ms] +/- 127ms
^* 111.230.189.174 2 9 377 236 +2895us[+2985us] +/- 29ms
^- ntp8.flashdance.cx 2 9 327 223 -11ms[ -11ms] +/- 196ms
^- ntp1.ams1.nl.leaseweb.net 2 9 377 29 +18ms[ +18ms] +/- 217ms
^+ time.neu.edu.cn 1 9 377 297 +765us[ +855us] +/- 30ms
oem@linuxmint:~$
--使用sourcestats命令显示有关chronyd当前正在检查的每个源的漂移率和偏移估算过程的信息
oem@linuxmint:~$ chronyc sourcestats
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
==============================================================================
alphyn.canonical.com 14 8 724 -1.937 6.880 -414us 1447us
prod-ntp-5.ntp1.ps5.cano> 10 7 717 -0.662 23.163 -19ms 3127us
pugot.canonical.com 12 5 787 -0.900 4.588 -23ms 1023us
prod-ntp-3.ntp4.ps5.cano> 11 8 722 +4.001 11.236 -21ms 1624us
time.cloudflare.com 15 9 786 -0.177 2.953 +8835us 677us
electrode.felixc.at 16 7 788 +0.033 17.115 -31ms 5000us
stratum2-1.ntp.mow01.ru.> 16 11 787 +0.467 3.503 +1003us 776us
111.230.189.174 16 8 784 +0.108 7.919 -337us 1945us
oem@linuxmint:~$
-- chronyd配置为客户端的时候,通过 chronyc ntpdata 命令向每一个 NTP 源发送/接收时间戳模式和交错模式的报告。
oem@linuxmint:~$ sudo chronyc ntpdata
[sudo] password for oem:
Remote address : 91.189.91.157 (5BBD5B9D)
Remote port : 123
Local address : 192.168.92.132 (C0A85C84)
Leap status : Normal
Version : 4
Mode : Server
Stratum : 2
Poll interval : 6 (64 seconds)
Precision : -23 (0.000000119 seconds)
Root delay : 0.076721 seconds
Root dispersion : 0.015793 seconds
Reference ID : 91EECB0E ()
Reference time : Fri Jan 20 03:21:24 2023
Offset : +0.000422822 seconds
Peer delay : 0.228727847 seconds
Peer dispersion : 0.000010693 seconds
Response time : 0.000015837 seconds
Jitter asymmetry: +0.00
NTP tests : 111 111 1111
Interleaved : No
Authenticated : No
TX timestamping : Daemon
RX timestamping : Kernel
Total TX : 18
Total RX : 15
Total valid RX : 15
Remote address : 185.125.190.58 (B97DBE3A)
Remote port : 123
Local address : 192.168.92.132 (C0A85C84)
Leap status : Normal
Version : 4
Mode : Server
Stratum : 2
Poll interval : 6 (64 seconds)
Precision : -25 (0.000000030 seconds)
Root delay : 0.001068 seconds
Root dispersion : 0.000443 seconds
Reference ID : A71C1419 ()
Reference time : Fri Jan 20 03:18:47 2023
Offset : -0.213448241 seconds
Peer delay : 0.704953432 seconds
Peer dispersion : 0.000025359 seconds
Response time : 0.000013336 seconds
Jitter asymmetry: +0.00
NTP tests : 111 111 1101
Interleaved : No
Authenticated : No
TX timestamping : Daemon
RX timestamping : Kernel
Total TX : 14
Total RX : 13
Total valid RX : 13
Remote address : 91.189.94.4 (5BBD5E04)
Remote port : 123
Local address : 192.168.92.132 (C0A85C84)
Leap status : Normal
Version : 4
Mode : Server
Stratum : 2
Poll interval : 6 (64 seconds)
Precision : -23 (0.000000119 seconds)
Root delay : 0.001923 seconds
Root dispersion : 0.024673 seconds
Reference ID : 11FD22FD ()
Reference time : Fri Jan 20 03:16:30 2023
Offset : -0.017117748 seconds
Peer delay : 0.362555832 seconds
Peer dispersion : 0.000010582 seconds
Response time : 0.000081327 seconds
Jitter asymmetry: +0.00
NTP tests : 111 111 1101
Interleaved : No
Authenticated : No
TX timestamping : Daemon
RX timestamping : Kernel
Total TX : 18
Total RX : 18
Total valid RX : 18
Remote address : 185.125.190.56 (B97DBE38)
Remote port : 123
Local address : 192.168.92.132 (C0A85C84)
Leap status : Normal
Version : 4
Mode : Server
Stratum : 2
Poll interval : 6 (64 seconds)
Precision : -25 (0.000000030 seconds)
Root delay : 0.001114 seconds
Root dispersion : 0.000168 seconds
Reference ID : B3D05EBE ()
Reference time : Fri Jan 20 03:19:36 2023
Offset : +0.022542598 seconds
Peer delay : 0.248375818 seconds
Peer dispersion : 0.000013721 seconds
Response time : 0.000009000 seconds
Jitter asymmetry: +0.50
NTP tests : 111 111 1111
Interleaved : No
Authenticated : No
TX timestamping : Daemon
RX timestamping : Kernel
Total TX : 20
Total RX : 14
Total valid RX : 14
Remote address : 162.159.200.123 (A29FC87B)
Remote port : 123
Local address : 192.168.92.132 (C0A85C84)
Leap status : Normal
Version : 4
Mode : Server
Stratum : 3
Poll interval : 6 (64 seconds)
Precision : -25 (0.000000030 seconds)
Root delay : 0.026688 seconds
Root dispersion : 0.000702 seconds
Reference ID : 0AD00804 ()
Reference time : Fri Jan 20 03:21:57 2023
Offset : -0.008113977 seconds
Peer delay : 0.181255892 seconds
Peer dispersion : 0.000009528 seconds
Response time : 0.000057939 seconds
Jitter asymmetry: -0.50
NTP tests : 111 111 1111
Interleaved : No
Authenticated : No
TX timestamping : Daemon
RX timestamping : Kernel
Total TX : 18
Total RX : 18
Total valid RX : 18
Remote address : 78.46.102.180 (4E2E66B4)
Remote port : 123
Local address : 192.168.92.132 (C0A85C84)
Leap status : Normal
Version : 4
Mode : Server
Stratum : 3
Poll interval : 6 (64 seconds)
Precision : -26 (0.000000015 seconds)
Root delay : 0.008759 seconds
Root dispersion : 0.025101 seconds
Reference ID : 550AF0FD ()
Reference time : Fri Jan 20 03:20:02 2023
Offset : +0.029730596 seconds
Peer delay : 0.259995103 seconds
Peer dispersion : 0.000013052 seconds
Response time : 0.000004604 seconds
Jitter asymmetry: +0.50
NTP tests : 111 111 1111
Interleaved : No
Authenticated : No
TX timestamping : Daemon
RX timestamping : Kernel
Total TX : 18
Total RX : 18
Total valid RX : 18
Remote address : 185.209.85.222 (B9D155DE)
Remote port : 123
Local address : 192.168.92.132 (C0A85C84)
Leap status : Normal
Version : 4
Mode : Server
Stratum : 2
Poll interval : 6 (64 seconds)
Precision : -25 (0.000000030 seconds)
Root delay : 0.001785 seconds
Root dispersion : 0.001404 seconds
Reference ID : C2BEA801 ()
Reference time : Fri Jan 20 03:16:10 2023
Offset : +0.001211682 seconds
Peer delay : 0.134713382 seconds
Peer dispersion : 0.000009404 seconds
Response time : 0.000042643 seconds
Jitter asymmetry: +0.00
NTP tests : 111 111 1111
Interleaved : No
Authenticated : No
TX timestamping : Daemon
RX timestamping : Kernel
Total TX : 18
Total RX : 18
Total valid RX : 18
Remote address : 111.230.189.174 (6FE6BDAE)
Remote port : 123
Local address : 192.168.92.132 (C0A85C84)
Leap status : Normal
Version : 4
Mode : Server
Stratum : 2
Poll interval : 6 (64 seconds)
Precision : -22 (0.000000238 seconds)
Root delay : 0.000092 seconds
Root dispersion : 0.023911 seconds
Reference ID : 647A24C4 ()
Reference time : Fri Jan 20 03:14:20 2023
Offset : -0.000154757 seconds
Peer delay : 0.012041230 seconds
Peer dispersion : 0.000009315 seconds
Response time : 0.000022826 seconds
Jitter asymmetry: -0.45
NTP tests : 111 111 1111
Interleaved : No
Authenticated : No
TX timestamping : Daemon
RX timestamping : Kernel
Total TX : 18
Total RX : 18
Total valid RX : 18
oem@linuxmint:~$
-- 绕过任何正在进行的缓慢调整,立即进行更新系统时间
chronyc makestep
-- 关于nptupdate和ntpd。
ntpupdate,和ntpd都可以同步时间,区别是,utpupdate可以一次性同步到位时间,生产生慎用
ntpd是逐步同步时间的
总结下今天学习Linux时间同步的情况。
Post by Linux Mint .2023-01-20
END