centos7.4 用chrony代替ntpd时间同步服务器

           Chrony是一个开源的自由软件,它能保持系统时钟与时钟服务器(NTP)同步,让时间保持精确。它由两个程序组成:chronyd和chronyc。
          chronyd是一个后台运行的守护进程,用于调整内核中运行的系统时钟和时钟服务器同步。它确定计算机增减时间的比率,并对此进行补偿。

          Chrony 是网络时间协议的另一种实现,与网络时间协议后台程序(ntpd)不同,它可以更快地且准确的同步系统时钟。

一、在服务器端的安装与配置

(1)安装# yum -y install chrony

Package chrony-3.1-2.el7.centos.x86_64 already installed and latest version

(2)编辑 /etc/chrony.conf 文件
按照你环境的要求,对下面的键进行添加,修改或者删除:server NTP_SERVER iburst
[root@controller1 ~]# cat /etc/chrony.conf 
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
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

使用NTP服务器的主机名或者IP地址替换 NTP_SERVER 。配置支持设置多个 server 值,默认使用上面四个

#修改允许客户端访问
# Allow NTP client access from local network.

allow 192.168.128.0/24

# systemctl enable chronyd.service

# systemctl start chronyd.service

(3)检查时间同步

[root@controller1 ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^? ntp1.ams1.nl.leaseweb.net     0   8     0     -     +0ns[   +0ns] +/-    0ns
^? ntp.wdc1.us.leaseweb.net      0   8     0     -     +0ns[   +0ns] +/-    0ns
^? 119.79-161-57.customer.l>     0   8     0     -     +0ns[   +0ns] +/-    0ns

^? ntp6.flashdance.cx            0   8     0     -     +0ns[   +0ns] +/-    0ns

[root@controller1 ~]# date

Wed May  9 11:14:36 CST 2018


二、在其它客户端的安装与配置

(1)同样在客户端安装# yum -y install chrony

Package chrony-3.1-2.el7.centos.x86_64 already installed and latest version

(2)编辑 /etc/chrony.conf 文件

[root@controller1 ~]# cat /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

server 192.168.128.101 iburst

# systemctl enable chronyd.service
# systemctl start chronyd.service

验证时间同步:
[root@mq1 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^? 192.168.128.101                   0   6     0     -     +0ns[   +0ns] +/-    0ns

[root@mq1 ~]# 


猜你喜欢

转载自blog.csdn.net/openbox2008/article/details/80250027