## 1. 安装
```
yum -y install chrony
```
## 2. 服务端配置
```
vi /etc/chrony.conf
#配置网络时间服务器
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
#以上可以修改为国内时间,这里保持默认的,按照您的需求修改就好
# 配置客户端的接入限制
allow 10.28.200.0/24
allow 10.29.0.0/16
# 配置本机时间
server 127.127.1.0
allow 127.0.0.0/8
local stratum 10
# 设置本地时间,是当没有外部源时间可以同步的时候,chrony采用本机的时间。查看到的状态如下:
[root@admin ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^? 127.127.1.0 0 7 0 - +0ns[ +0ns] +/- 0ns
systemctl restart chronyd
systemctl enable chronyd
[root@admin ~]# chronyc sources
210 Number of sources = 5
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^? 127.127.1.0 10 6 1 3 -451ns[ -451ns] +/- 9243ns
^? ntp7.flashdance.cx 0 6 0 - +0ns[ +0ns] +/- 0ns
^? 85.199.214.101 1 6 1 2 +23ms[ +23ms] +/- 108ms
^? 61-216-153-106.HINET-IP.> 3 6 1 2 -368us[ -368us] +/- 107ms
^? ntp5.flashdance.cx 0 6 0 - +0ns[ +0ns] +/- 0ns
```
## 3 客户端配置
```
vi /etc/chrony.conf
sed -i "s/server/#server/g" /etc/chrony.conf
echo "server admin iburst" >>/etc/chrony.conf
systemctl restart chronyd
[root@mon3 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* admin.sysit.cn 10 6 17 57 -4484ns[-5519ns] +/- 48us
```