chrony时间同步
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了chrony时间同步相关的知识,希望对你有一定的参考价值。
参考技术A linux在运行时间长了之后,尤其在虚拟环境中。系统时间可能会存在一定的误差,时间同步在大型集群环境中是很重要的,而通过ntp协议来同步时间,则是一个很好的解决方案。在CentOS6中,默认是使用ntpd来同步时间的,但ntpd同步时间并不理想,有可能需要数小时来同步时间,所以在Centos7中换成了chrony来实现时间同步。chrony并且兼容ntpd监听在udp123端口上,自己则监听在udp的323端口上。
如果在chrony配置文件中指定了ntp服务器的地址,那么chrony就是一台客户端,会去同步ntp服务器的时间,如果在chrony配置了允许某些客户端来向自己同步时间,则chrony也充当了一台服务器,所以,安装了chrony即可充当客户端也可以充当服务端。
chrony自带一个交互式工具chronyc,在配置文件中指定了时间服务器之后,如果想查看同步状态,可以进入这个交互式工具的交互界面。
chrony时间同步 服务端 客户端 安装配置
chrony时间同步 服务端 客户端 安装配置
原创内容http://www.cnblogs.com/elvi/p/7658021.html
#!/bin/sh #运行环境 centos7 #chrony时间同步 服务端 客户端 安装配置 #安装 yum install chrony -y cp /etc/chrony.conf{,.bak} #备份默认配置 #chrony服务配置 echo " # #外部NTP服务# server ntp6.aliyun.com iburst server cn.ntp.org.cn iburst server ntp.shu.edu.cn iburst driftfile /var/lib/chrony/drift driftfile /var/lib/chrony/drift makestep 1.0 3 rtcsync logdir /var/log/chrony ">/etc/chrony.conf #chrony作为内网NTP服务配置 echo " # #外部NTP服务 server ntp6.aliyun.com iburst server cn.ntp.org.cn iburst server ntp.shu.edu.cn iburst driftfile /var/lib/chrony/drift makestep 1.0 3 rtcsync # #内网 allow 10.2.1.0/24 allow 172.16.11.0/24 bindcmdaddress 127.0.0.1 bindcmdaddress ::1 keyfile /etc/chrony.keys commandkey 1 generatecommandkey noclientlog logchange 0.5 logdir /var/log/chrony ">/etc/chrony.conf #chrony使用内网NTP服务配置 echo " # #内部NTP服务 server 10.2.1.10 iburst server ntp6.aliyun.com iburst driftfile /var/lib/chrony/drift makestep 1.0 3 rtcsync logdir /var/log/chrony ">/etc/chrony.conf #启动 systemctl start chronyd systemctl enable chronyd #开机启动 systemctl restart chronyd chronyc sources #查看同步源 ##查看 chronyc sources #服务端 # 210 Number of sources = 3 # MS Name/IP address Stratum Poll Reach LastRx Last sample # =============================================================================== # ^* time6.aliyun.com 2 6 377 71 -2307us[-3126us] +/- 20ms # ^+ xk-6-95-a8.bta.net.cn 2 6 377 7 +767us[ +767us] +/- 62ms # ^- ntp.shu.edu.cn 2 6 377 7 -11ms[ -11ms] +/- 419ms # # chronyc sources #客户端 # 210 Number of sources = 1 # MS Name/IP address Stratum Poll Reach LastRx Last sample # =============================================================================== # ^* kweb.w.dev 3 6 377 44 -99us[ +160us] +/- 21ms
以上是关于chrony时间同步的主要内容,如果未能解决你的问题,请参考以下文章