赞
踩
chrony是网络时间协议(NTP)的通用实现。它可以将系统时钟与NTP服务器,参考时钟(例如GPS接收器)以及使用手表和键盘进行的手动输入进行同步。它还可以充当NTPv4(RFC 5905)服务器并与之同行,以向网络中的其他计算机提供时间服务。
它被设计为在各种条件下均能良好运行,包括间歇性网络连接,网络严重拥塞,温度变化(普通计算机时钟对温度敏感)以及无法连续运行或在虚拟机上运行的系统。
通过Internet同步的两台计算机之间的典型精度在几毫秒内;在LAN上,精度通常为数十微秒。使用硬件时间戳记或硬件参考时钟,亚微秒精度是可能的。
chrony包括两个程序,chronyd一个是守护程序,可以在引导时启动,chronyc另一个是命令行界面程序,可以用来监视其chronyd性能并在运行时更改各种操作参数。目前centos7已经默认安装chrony3.2作为时钟服务。
[root@test1 ~]# yum install -y chrony
#注释如下四行
# server 0.centos.pool.ntp.org iburst
# server 1.centos.pool.ntp.org iburst
# server 2.centos.pool.ntp.org iburst
# server 3.centos.pool.ntp.org iburst
#设置阿里云时钟同步服务器作为时钟源
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
#设置运行使用通过此服务器同步时钟的网段
allow 192.168.10.0/24
[root@test1 ~]# systemctl start chronyd
[root@test1 ~]# systemctl status chronyd
[root@test1 ~]# systemctl enable chronyd
^*表示当前选择的时钟源,^表示有效的时钟源服务器
[root@test1 ~]# chronyc sources
210 Number of sources = 2
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 120.25.115.20 2 7 377 123 +1733us[+1679us] +/- 13ms
^+ 203.107.6.88 2 7 377 123 -6546us[-6546us] +/- 39ms
[root@test1 ~]# yum install -y chrony
#注释如下四行
# server 0.centos.pool.ntp.org iburst
# server 1.centos.pool.ntp.org iburst
# server 2.centos.pool.ntp.org iburst
# server 3.centos.pool.ntp.org iburst
#设置局域网时钟同步服务器作为时钟源
server 192.168.0.124 iburst
[root@test1 ~]# systemctl start chronyd
[root@test1 ~]# systemctl status chronyd
[root@test1 ~]# systemctl enable chronyd
[root@test2 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.0.124 3 6 377 60 +353us[-1166us] +/- 36ms
配置文件路径/etc/chrony.conf
[root@test2 ~]# chronyc
chrony version 3.4
Copyright © 1997-2003, 2007, 2009-2018 Richard P. Curnow and others
chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are welcome to redistribute it under certain conditions. See the
GNU General Public License version 2 for details.
chronyc>
[root@test2 ~]# chronyc activity
200 OK
1 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@test2 ~]# chronyc add server 192.168.0.131
200 OK
[root@test2 ~]# chronyc sources
210 Number of sources = 2
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.0.124 3 6 377 60 -287us[ -420us] +/- 14ms
^? 192.168.0.131 11 6 1 4 +36ms[ +36ms] +/- 2085us
[root@test1 ~]# chronyc clients
Hostname NTP Drop Int IntL Last Cmd Drop Int Last
===============================================================================
192.168.0.125 40 0 6 - 49 0 0 - -
[root@test2 ~]# chronyc delete 192.168.0.131
200 OK
[root@test2 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.0.124 3 6 377 23 -300us[ -422us] +/- 15ms
[root@test2 ~]# chronyc settime
505 Facility not enabled in daemon
[root@test2 ~]# chronyc tracking
Reference ID : C0A8007C (192.168.0.124)
Stratum : 4
Ref time (UTC) : Fri Jan 15 08:52:16 2021
System time : 0.000000299 seconds fast of NTP time
Last offset : -0.000250601 seconds
RMS offset : 0.000372452 seconds
Frequency : 33.019 ppm slow
Residual freq : -1.977 ppm
Skew : 4.737 ppm
Root delay : 0.022533407 seconds
Root dispersion : 0.005204781 seconds
Update interval : 64.4 seconds
Leap status : Normal
[root@test2 ~]# chronyc -help
chrony version 3.4
Copyright © 1997-2003, 2007, 2009-2018 Richard P. Curnow and others
chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are welcome to redistribute it under certain conditions. See the
GNU General Public License version 2 for details.
Could not open connection to daemon
[root@test2 ~]# chronyc sources -v
210 Number of sources = 1
.-- Source mode ‘^’ = server, ‘=’ = peer, ‘#’ = local clock.
/ .- Source state ‘*’ = current synced, ‘+’ = combined , ‘-’ = not combined,
| / ‘?’ = unreachable, ‘x’ = time may be in error, ‘~’ = time too variable.
|| .- 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
===============================================================================
^* 192.168.0.124 3 6 377 39 -301us[-1206us] +/- 16ms
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。