一 Chrony概览

1.1 Chrony简介

Chrony是一个开源的自由软件,是网络世界协议(NTP)的另一种实现,它能保持系统时钟与时钟服务器(NTP)同步,让时间保持精确。

它由两个程序组成:chronyd和chronyc。

chronyd:一个后台运行的守护进程,用于调整内核中运行的系统时钟和时钟服务器同步。它确定计算机增减时间的比率,并对此进行补偿。

chronyc提供了一个用户界面,用于监控性能并进行多样化的配置。它可以在chronyd实例控制的计算机上工作,也可以在一台不同的远程计算机上工作。

1.2 Chrony优点

  • 更快的同步只需要数分钟而非数小时世界,从而最大程度减少了时间和频率误差;
  • 能够更好的响应时钟频率的快速变化,对于具备不稳定时钟的虚拟机或导致时钟频繁发生变化的节能结束非常有用;
  • 在初始同步后,它不会停止时钟,以防对需要系统时间保持单调的应用程序造成影响;
  • 在应对临时非对称延时时提供了更好的稳定性;
  • 无需对服务器进行定期轮询,因此具备间歇性网络连接的系统仍然可以快速同步时钟。

二 Chrony安装与配置

2.1 架构及准备

节点主机
IP
主机名
NTP-Server
172.24.8.30/24
ntpserver
NTP-Client
172.24.8.31/24
ntpclient

主机名修改:略。

2.1 安装

 [root@ntpserver ~]# yum install -y chrony

注意:client节点同样需要安装。

2.2 服务节点chrony配置

 [root@ntpserver ~]# vi /etc/chrony.conf

 server ntp1.aliyun.com iburst

 server ntp2.aliyun.com iburst

 server ntp3.aliyun.com iburst #采用阿里云时钟源

 allow 172.24.8.0/24 #允许客户端所在网段

 bindcmdaddress 127.0.0.1

 bindcmdaddress ::1

 local stratum 10 #设置源时钟等级
 

注意:以上给出关键部分配置,其他部分采用默认即可,具体配置参数见附录1。

2.3 服务节点启动验证

 [root@ntpserver ~]# systemctl start chronyd.service
[root@ntpserver ~]# systemctl enable chronyd.service
[root@ntpserver ~]# systemctl status chronyd.service

 [root@ntpserver ~]# chronyc sources -v		#查看同步情况

2.4 客户端节点chrony配置

 [root@ntpclient ~]# vi /etc/chrony.conf
server ntpserver iburst #指定同步源为ntpserver

附录1 配置文件详解

/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

 # 该参数可多次用于添加时钟服务器,必须以"server "格式使用。

 # Record the rate at which the system clock gains/losses time.

 driftfile /var/lib/chrony/drift

 # chronyd程序的主要行为之一,就是根据实际时间计算出计算机增减时间的比率,将它记录到一个文件中是最合理的,它会在重启后为系统时钟作出补偿,甚至可能的话,会从时钟服务器获得较好的估值。

 # Allow the system clock to be stepped in the first three updates

 # if its offset is larger than 1 second.

 makestep 1.0 3

 # 通常,chronyd将根据需求通过减慢或加速时钟,使得系统逐步纠正所有时间偏差。在某些特定情况下,系统时钟可能会漂移过快,导致该调整过程消耗很长的时间来纠正系统时钟。该指令强制chronyd在调整期大于某个阀值时步进调整系统时钟,但只有在因为chronyd启动时间超过指定限制(可使用负值来禁用限制),没有更多时钟更新时才生效。

 # Enable kernel synchronization of the real-time clock (RTC).

 rtcsync

 # rtcsync指令将启用一个内核模式,在该模式中,系统时间每11分钟会拷贝到实时时钟(RTC)。

 # Enable hardware timestamping on all interfaces that support it.

 #hwtimestamp *

 # Increase the minimum number of selectable sources required to adjust

 # the system clock.

 #minsources 2

 # Allow NTP client access from local network.

 #allow 192.168.0.0/16

 #deny 192.168/16

 # 指定一台主机、子网,或者网络以允许或拒绝NTP连接到扮演时钟服务器的机器。

 # Listen for commands only on localhost.

 bindcmdaddress 127.0.0.1

 bindcmdaddress ::1

 # 该指令允许你限制chronyd监听哪个网络接口的命令包(由chronyc执行)。该指令通过cmddeny机制提供了一个除上述限制以外可用的额外的访问控制等级。

 # Serve time even if not synchronized to a time source.

 #local stratum 10

 # Specify file containing keys for NTP authentication.

 #keyfile /etc/chrony.keys

 # Specify directory for log files.

 logdir /var/log/chrony

 # Select which information is logged.

 #log measurements statistics tracking
 

参考:https://www.cnblogs.com/Csir/p/6912527.html

xhy 标记: chrony

最新文章

  1. C++11—lambda函数
  2. ExtJs4 SpringMvc3 实现Grid 分页
  3. OpenJudge 2803 碎纸机 / Poj 1416 Shredding Company
  4. Windows server 2008下开启telnet功能
  5. C语言数据输入与输出
  6. javascript对象属性——数据属性和访问器属性
  7. CodeForces 22B Bargaining Table 简单DP
  8. NHibernate总结
  9. 大数加法(STL list)
  10. 微信小程序t填坑之旅一(接入)
  11. springmvc 导出excel
  12. Spring Cloud中Feign如何统一设置验证token
  13. UOJ #269. 【清华集训2016】如何优雅地求和
  14. iOS -- Effective Objective-C 阅读笔记 (6)
  15. python mac 环境配置
  16. java 两个List集合各种情况对比处理
  17. C#介绍RabbitMQ使用篇一HelloWorld
  18. Delphi XE以后的版本 程序如何瘦身
  19. CrackMe005-下篇 | 逆向破解分析 | 160个CrackMe(视频+图文)深度解析系列
  20. JavaScript限制前端页面用户表单输入

热门文章

  1. spring data jpa查询部分字段、多余附加字段
  2. Atcoder Grand 011 C - Squared Graph
  3. JS控制form表单action去向
  4. python---django中orm的使用(3)admin配置与使用
  5. Spark记录-官网学习配置篇(一)
  6. 那些年的 网络通信之 TCP/IP 传输控制协议 ip 加 端口 ---
  7. html5 canvas 填充渐变形状
  8. JavaScript继承详解(四)
  9. iOS 自己封装的网络请求,json解析的类
  10. IIS发布,无法显示CSS样式和图片