Chrony是CentOS 7發行之後用來取代ntp的系統校時工具,安裝設定都很簡易,留個操作筆記~ 🤖🤓🤖
# 變更伺服器的時區設定
sudo timedatectl set-timezone Asia/Taipei
sudo timedatectl set-ntp yes
# 安裝Chrony系統校時工具
yum install -y epel-release sudo
sudo yum install -y chrony
# 更換伺服器並啟動該服務
1 2 3 4 |
cp /etc/chrony.conf /etc/chrony.conf.bak sed -i '/pool.ntp.org/a\server time.cloudflare.com prefer\nserver time.google.com prefer\nserver clock.fmt.he.net iburst\nserver clock.nyc.he.net iburst\nserver time.nist.gov iburst\nserver 0.amazon.pool.ntp.org iburst\nserver time.stdtime.gov.tw' /etc/chrony.conf # cat /etc/chrony.conf | grep server systemctl enable chronyd && systemctl start chronyd |
# 防火牆設定
systemctl iptables stop
iptables -A INPUT -p tcp --dport 123 -j ACCEPT
iptables-save | tee /etc/sysconfig/iptables
systemctl restart iptables
# firewalld切換成下列指令
firewall-cmd --permanent --add-service=ntp
firewall-cmd --reload
# 對時
sudo chronyc -a makestep && timedatectl
# 查看與ntp server的同步狀態與ntp server的時間差
sudo chronyc sources -v && timedatectl
# 顯示有關系統時間的資訊
sudo chronyc tracking
# 顯示同步源頭的資訊
sudo chronyc sourcestats -v
ref.