叢集環境下,所有節點時間必須一致。本文說明 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.orgtw.pool.ntp.orgtime.stdtime.gov.tw(國家標準時間中心)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
完成設定後,叢集節點時間將自動保持同步,避免日誌時間錯亂、驗證失效等問題。