一刹帕、chrony簡介
NTP:Network Time Protocol 網(wǎng)絡時間協(xié)議
Chrony?應用本身已經(jīng)有幾年了,其是是網(wǎng)絡時間協(xié)議的 (NTP) 的另一種實現(xiàn)丙号。
Chrony可以同時做為ntp服務的客戶端和服務端
一直以來眾多發(fā)行版里標配的都是ntpd對時服務乏梁,自rhel7/centos7 起,Chrony做為了發(fā)行版里的標配服務似炎,不過老的ntpd服務依舊在rhel7/centos7里可以找到 辛萍。
Chrony有兩個核心組件:
chronyd:是守護進程,主要用于調整內核中運行的系統(tǒng)時間和時間服務器同步羡藐。它確定計算機增減時間的比率贩毕,并對此進行調整補償。
chronyc:提供一個用戶界面仆嗦,用于監(jiān)控性能并進行多樣化的配置耳幢。它可以在chronyd實例控制的計算機上工作,也可以在一臺不同的遠程計算機上工作欧啤。
chrony用來同步時間睛藻,來代替ntp服務,優(yōu)點是很精巧的時間同步工具邢隧,更快響應時鐘變化店印,在應對延時提供更好的穩(wěn)定性能,不會出現(xiàn)時間空白倒慧,跨越互聯(lián)網(wǎng)同步時間只需要幾毫秒按摘。
二、實驗環(huán)境
操作系統(tǒng): CentOS7.x
chronyServer? 192.168.1.106
chronyClient? 192.168.1.100
三纫谅、軟件安裝
在chronyServer 和chronyClient 服務器:
#?yum -y install chrony
# rpm -ql chrony
開啟防火墻
#? 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
查看服務端綁定的IP和端口監(jiān)聽
# ss? -uan?
chronyd默認監(jiān)聽兩個端口: 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
# ss -uan
注意:chrony作為客戶端是采用隨機的udp端口與服務端進行通訊的唠摹,但是我們可以綁定客戶端socket的的IP和端口爆捞,以便于相應的防火墻管理控制,,本客戶端勾拉,我們配置的與服務端通訊的端口為 1234煮甥。
#? watch chronyc tracking
六、參考
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
http://www.reibang.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 系統(tǒng)上 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/