Chrony时间服务

Chrony服务端配置

#Chrony安装(既可以做服务端,又可以做客户端)
[root@chrony-server ~]# yum -y install chrony

#配置Chrony服务端
[root@chrony-server ~]# cat /etc/chrony.conf | egrep -v "^#|^$"
#配置阿里云的时间同步服务器地址(一个或多个)
server ntp.aliyun.com iburst
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
#允许哪个网段的机器过来同步时间
allow 172.16.1.0/24
#即使同步公网时间失败,也提供授时服务
local stratum 10

#重启Chrony服务
[root@chrony-server ~]# systemctl restart chronyd

Chrony客户端配置

#安装Chrony同步时间的客户端(可以是chronyc也可以是ntpdate)
[root@chrony-client ~]# yum -y install chrony

[root@chrony-client ~]# yum -y install ntpdate

#客户端使用ntpdate进行手动时间同步
[root@chrony-client ~]# ntpdate 172.16.1.128
 7 May 08:12:01 ntpdate[1298]: adjust time server 172.16.1.128 offset -0.021651 sec

#客户端使用Chrony进行手动时间同步
[root@chrony-client ~]# chronyc -a makestep
200 OK

#客户端使用Chrony守护进程的方式进行时间自动化同步

[root@chrony-client ~]# vim /etc/chrony.conf 
#时间同步服务器的地址指向内网地址Chrony的服务端
server 172.16.1.128 iburst

#重启客户端的Chronyd服务
[root@chrony-client ~]# systemctl restart chronyd

#查看时间同步是否正常
[root@chrony-client ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* 172.16.1.128                  3   6    37     6   +558ns[+3527us] +/-   19ms

#查看时间同步详细信息
[root@chrony-client ~]# 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               
===============================================================================
^* 172.16.1.128                  3   6    37     9   +558ns[+3527us] +/-   19ms

 

你可能感兴趣的:(linux)