Chrony是一個開源的自由軟件,它能保持系統時鍾與時鍾服務器(NTP)同步,讓時間保持精確。
它由兩個程序組成:chronyd和chronyc。
chronyd是一個后台運行的守護進程,用於調整內核中運行的系統時鍾和時鍾服務器同步。
它確定計算機增減時間的比率,並對此進行補償。
對於孤立系統,用戶可以手動周期性的輸入正確時間(通過chronyc)。
在這兩種情況下,chronyd決定計算機快慢的比例,並加以糾正。
chronyd實現了NTP協議並且可以作為服務器或客戶端。
chronyc是用來監控chronyd性能和配置其參數的用戶界面。
他可以控制本機及其他計算機上運行的chronyd進程。
本次主要講一下Chrony的安裝與配置:
【服務器端】
- 安裝
yum install -y chrony |
- 編輯配置文件
vim /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 192.168.128.0/24 |
允許客戶端訪問
- 重啟服務
systemctl enable chronyd systemctl start chronyd |
- 檢查時間同步
chronyc sources |
【客戶端】
- 安裝
yum install -y chrony |
- 編輯配置文件
vim /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_SERVER,使用我們自己的服務器端的IP作為NTP_SERVER 。
- 重啟服務
systemctl enable chronyd systemctl start chronyd |
- 檢查時間同步
chronyc sources |