| 命令 | 用途 | 關鍵輸出解讀 |
|---|---|---|
ntpstat |
查看同步狀態 | synchronised to NTP server (IP) at stratum 3 = 正常;unsynchronised = 需重啟同步 |
ntpq -p |
查看上游服務器列表 | * 當前主用、+ 備選、st 層級、delay/offset/jitter 延遲指標 |
ntpdate <server> |
手動單次同步 | 需先 service ntpd stop 釋放端口 |
service ntpd start/stop/restart |
服務控制 | - |
chkconfig ntpd on |
啟用開機自啟 | Runlevel 2,3,4,5 顯示 on 即正確 |
chkconfig --list ntpd |
驗證自啟配置 | ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off |
ntpstat → 若 Unable to talk to NTP daemon 進入步驟 2chkconfig ntpd onservice ntpd startntpstat 等待顯示 synchronised(可能需數分鐘)service ntpd stop
ntpdate cn.pool.ntp.org # 或時間源
service ntpd start
編輯 /etc/ntp.conf:
# 預設 pool 註釋掉
# 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
# 指定內網授時服務器或可信公共源
server 192.168.1.100 iburst prefer # 內網主時鐘
server ntp.aliyun.com iburst # 阿里云公共 NTP
server time.cloudflare.com iburst # Cloudflare
# 允許內網客戶端同步
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
修改後 service ntpd restart 生效。
iptables -A INPUT -p udp --dport 123 -j ACCEPT)ntpstat 長期 unsynchronised:檢查 ntpq -p 的 reach 值(八進制,377=全通),為 0 表示無法連達上游vmware-tools/open-vm-tools 並啟用宿主機時間同步,或縮短輪詢間隔 minpoll 4/maxpoll 10offset 絕對值 < 10ms、jitter < 5ms、reach=377