chrony 时间校准

警告
本文最后更新于 2021-05-18,文中内容可能已过时。

安装

1
yum -y install chrony

配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## 配置文件修改
vim /etc/chrony.conf

## 把不需要的 server 注释掉
## 然后增加需要时间对准的服务器IP
server ntp2.xtp.com iburst
server 10.228.39.1 iburst

driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
## 如果是服务器,需要开启这个允许IP接入
## allow 10.36.0.0/16
logdir /var/log/chrony

服务

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
systemctl enable chronyd.service
systemctl start chronyd.service
systemctl status chronyd.service -l

#确认同步来源的状态
chronyc activity

#立即手工同步
chronyc -a makestep

#查看时间同步源
chronyc sources -v

#查看时间同步源状态
chronyc sourcestats -v

#校准时间服务器
chronyc tracking -v

#硬件时间默认为UTC
timedatectl set-local-rtc 1

查看结果

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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
===============================================================================

^* 10.228.39.1                   1   6     7     2   -574us[ +411us] +/- 1500ms

相关内容

william 支付宝支付宝
william 微信微信
0%