服务的名称 : chronyd
在服务端:
vim /etc/chrony.conf
删除以下代码的注释
22 allow 172.25.36.0/24 #允许哪些客户端来同步本机的时间
29 local stratum 10 #本机不同步任何主机的时间,本机作为时间源
systemctl restart chronyd.service
timedatectl set-timezone Asia/Shanghai #更改当前时区
在客户端:
vim /etc/chrony.conf
3 server 172.25.35.86 #本机同步172.25.35.86主机的时间
timedatectl set-timezone Asia/Shanghai #同步当前时区
/etc/chrony.conf修改好后如下图
Screenshot from 2019-01-13 14-46-36.png
测试:
在客户端:
[root@desktop ~]# 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
|| / xxxx = adjusted offset,
|| Log2(Polling interval) -. | yyyy = measured offset,
|| \ | zzzz = estimated error.
|| | |
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 172.25.36.86 10 6 17 13 -2994ns[ -46us] +/- 1166us