Linux: 时间服务器chrony

时间服务器chrony

在集群中,机器的时间一致性是非常重要的,有些机器无法直接连接外网,进行不了ntp对时,这种情况我们就要搭建一台时间服务器,让时间服务器去与外网对时,然后让其他机器向它对时即可。

环境
时间服务器: 192.168.186.10 主机名:zabbix-server
其他服务器: 192.168.186.11 主机名:zabbix-agent-1
其他服务器: 192.168.186.12 主机名:zabbix-agent-2
安装chrony(所有机器)

[root@zabbix-server ~]# yum -y install chrony
[root@zabbix-agent-1 ~]# yum -y install chrony
[root@zabbix-agent-2 ~]# yum -y install chrony

配置时间服务器(192.168.186.10)

[root@zabbix-server ~]# vim /etc/chrony.conf
...
# Allow NTP client access from local network.
allow 192.168.186.0/24
...
#只需打开允许其他机器向它同步即可
[root@zabbix-server ~]# systemctl start chronyd.service
[root@zabbix-server ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^? a.chl.la                      0   6     0     -     +0ns[   +0ns] +/-    0ns
^? ntp8.flashdance.cx            2   6    46     5    -21ms[  -11ms] +/-  218ms
^* ntp6.flashdance.cx            2   6    51     4  -9061us[+5955us] +/-  187ms
^? ntp.wdc1.us.leaseweb.net      2   6    41     5    -27ms[  -12ms] +/-  274ms

配置需要对时的机器(192.168.186.11 192.168.186.12)

[root@zabbix-agent-1 ~]# vim /etc/chrony.conf
...
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 192.168.186.10 iburst
#将时间同步的机器指向刚刚配置的时间服务器,删除默认的时间服务器
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
....
[root@zabbix-agent-1 ~]# systemctl start chronyd.service
[root@zabbix-agent-1 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^? 192.168.186.10                3   6    17     0   +692ms[ +692ms] +/-  10.7s
#其他服务器也是一样这样配置

配置完成!

猜你喜欢

转载自blog.csdn.net/rookie23rook/article/details/110423939