[CentOS7]chrony 时间同步

参考文献

https://docs.fedoraproject.org/en-US/Fedora/18/html/System_Administrators_Guide/sect-Checking_if_chrony_is_synchronized.html

安装

yum install -y chrony

修改配置文件

cp /etc/chrony.conf /etc/chrony.conf.bak
sed -i '/^server/d' /etc/chrony.conf
sed -i '2a server ntp1.aliyun.com' /etc/chrony.conf
sed -i '2a server ntp2.aliyun.com' /etc/chrony.conf
sed -i '2a server ntp3.aliyun.com iburst\nallow 10/8' /etc/chrony.conf

启动服务

systemctl start chronyd && systemctl enable chronyd

设置时区

timedatectl set-timezone Asia/Shanghai

查看时间源

[root@ntp ~]# chronyc sources -v
210 Number of sources = 2

  .-- 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
===============================================================================
^* 203.107.6.88                  2   6    17    38   -883us[-2553us] +/-   20ms
^? 120.25.115.20                 2   6     1    44   +624us[-3946ms] +/-   25ms

强制更新时间

chronyc -a makestep

END

posted @ 2020-05-04 10:06  LeoShi2020  阅读(943)  评论(0编辑  收藏  举报