【chrony】CentOS7.2 上chrony的安装与配置

一、chrony简介


12979420-e2af372c9794f31f.png

NTP:Network Time Protocol 网络时间协议

Chrony 应用本身已经有几年了,其是是网络时间协议的 (NTP) 的另一种实现。

Chrony可以同时做为ntp服务的客户端和服务端

一直以来众多发行版里标配的都是ntpd对时服务,自rhel7/centos7 起,Chrony做为了发行版里的标配服务,不过老的ntpd服务依旧在rhel7/centos7里可以找到 。

Chrony有两个核心组件:

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

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

12979420-f3611bedde385bd5.png

chrony用来同步时间,来代替ntp服务,优点是很精巧的时间同步工具,更快响应时钟变化,在应对延时提供更好的稳定性能,不会出现时间空白,跨越互联网同步时间只需要几毫秒。


12979420-1d41964a58fefb6d.png

二、实验环境

操作系统: CentOS7.x

chronyServer  192.168.1.106

chronyClient  192.168.1.100

三、软件安装

在chronyServer 和chronyClient 服务器:

# yum -y install chrony

# rpm -ql chrony


12979420-8675f95539ba1c55.png


开启防火墙

#  firewall-cmd --add-service=ntp  --permanent

# firewall-cmd --reload


关闭selinux

# setenforce 0

# sed -i 's/^SELINUX=.*/SELINUX=permissive/g'  /etc/selinux/config


四、配置chronyServer 

在chronyServer服务器:

# vim /etc/chrony.conf

#########################

server pool.ntp.org iburst prefer

server 192.168.1.106 iburst

driftfile /var/lib/chrony/drift

makestep 1.0 3

rtcsync

allow 192.168.1.0/24

local stratum 10

logdir /var/log/chrony

bindaddress 192.168.1.106

port 123

###############################

# systemctl start chronyd

# systemctl enable chronyd

#  systemctl status  chronyd


12979420-f6183efeba17480f.png

查看服务端绑定的IP和端口监听

# ss  -uan 


12979420-60d5ea22ce7a7816.png


chronyd默认监听两个端口: 123/udp   323/udp

123/udp  ,是供客户端通讯连接用的,安全起见,请绑定服务端socket的IP,而不是0.0.0.0

323/udp,供chronyc连接用,安全起见,默认绑定的本地socket的IP为 127.0.0.1

五、配置chronyClient

在chronyClient服务器:

# vim /etc/chrony.conf

################################

server 192.168.1.106 iburst

driftfile /var/lib/chrony/drift

makestep 1.0 3

rtcsync

logdir /var/log/chrony

bindacqaddress  192.168.1.100

acquisitionport  1234

#######################################

# systemctl start chronyd

# systemctl enable chronyd

#  systemctl status  chronyd

12979420-3d02e4200c767444.png

# ss -uan


12979420-c8c5f3c9dbd6b10e.png

注意:chrony作为客户端是采用随机的udp端口与服务端进行通讯的,但是我们可以绑定客户端socket的的IP和端口,以便于相应的防火墙管理控制,,本客户端,我们配置的与服务端通讯的端口为 1234。


12979420-f74253f0321114e4.png


#  watch chronyc tracking


12979420-d8a459f555d39a5f.png

六、参考

Chrony Introduction

https://chrony.tuxfamily.org/

https://wiki.archlinux.org/index.php/Chrony

chrony.conf(5) Manual Page

https://chrony.tuxfamily.org/doc/3.4/chrony.conf.html

CentOS / RHEL 7 : Chrony V/s NTP (Differences Between ntpd and chronyd)

https://www.thegeekdiary.com/centos-rhel-7-chrony-vs-ntp-differences-between-ntpd-and-chronyd/

CHAPTER 17. CONFIGURING NTP USING THE CHRONY SUITE

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-configuring_ntp_using_the_chrony_suite

CentOS 7.x中正确设置时间与时钟服务器同步

https://linux.cn/article-4764-1.html

https://www.jianshu.com/p/a8cc55c894e9?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

chronyd Can't synchronise: no majority

https://forums.fedoraforum.org/showthread.php?298929-Automatic-time-set

CentOS / RHEL 7 : How to sync chrony to local clock

https://www.thegeekdiary.com/centos-rhel-7-chrony-how-to-sync-to-local-clock/

Manage NTP with Chrony

https://opensource.com/article/18/12/manage-ntp-chrony

Chrony:一个类 Unix 系统上 NTP 客户端和服务器替代品

https://linux.cn/article-10250-1.html

How to Install and Use Chrony in Linux

https://www.tecmint.com/install-chrony-in-centos-ubuntu-linux/

猜你喜欢

转载自blog.csdn.net/weixin_34302798/article/details/87552780