Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 使用 NTP 服務同步多台伺服器時間完整設定教學

編輯:Linux 教學

叢集環境下,所有節點時間必須一致。本文說明 NTP 服務的狀態檢查、手動同步、啟動與開機自啟完整流程。

一、檢查 NTP 狀態

ntpstat
# 未啟動:Unable to talk to NTP daemon. Is it running?
# 正常:synchronised to NTP server (198.55.111.5) at stratum 3
# 異常:unsynchronised → 需重啟 ntpd

二、查看上游伺服器清單

ntpq -p
# * 表目前同步來源,+ 表候選,空白表不可用

三、手動同步時間

service ntpd stop
ntpdate cn.pool.ntp.org
# 成功顯示:adjust time server xxx
service ntpd start

四、設定開機自啟

chkconfig ntpd on
chkconfig --list ntpd
# 應顯示 2:on 3:on 4:on 5:on

五、常用上游伺服器推薦(台灣/中國)

  • cn.pool.ntp.org
  • tw.pool.ntp.org
  • time.stdtime.gov.tw(國家標準時間中心)

六、/etc/ntp.conf 關鍵設定

restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
server cn.pool.ntp.org iburst
server tw.pool.ntp.org iburst
driftfile /var/lib/ntp/drift

完成設定後,叢集節點時間將自動保持同步,避免日誌時間錯亂、驗證失效等問題。

Copyright © Windows教程網 All Rights Reserved