NTP時鍾同步學習記錄


# NTP機制流程學習小記  2016-12-1
要點回顧 . 1. NTP唯一配置文件:/etc/ntp.conf . 2. NTP系統日志記錄:/var/log/ntp . 3. ntp.conf簡要介紹
- 利用 restrict 來管理權限控制:
   
restrict IP地址 #允許該IP在本機NTP服務器進行查詢和同步
- 利用server設定NTP上級服務器:
server [IP or hostname] [prefer] . 4. 手動同步上級IP時間(可用於檢測上級ntp服務是否正常):
   # ntpdate IP地址
   或者:
# sntp
-P no -r IP地址 // 備注:Suse 11版本中摒棄了ntpdate命令,采用新的sntp命令操作
1   查詢命令"ntpq -p"
1.1 "ntpq -p"展示server順序:與ntp.conf中server配置的前后順序一致。
    # 查詢狀態如下:
    svr-0:/opt/***/bin # ntpq -np
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
    *10.148.146.28   LOCAL(0)        11 u   55   64  377    0.449    0.021   0.022
     LOCAL(0)        .LOCL.           5 l   27   64  377    0.000    0.000   0.001
     # 備注:『*』代表目前正在使用的上級NTP;『+』代表已經連上,作為下一個供對時的侯選者
     
1.2 ntp獲取上級時鍾源順序,按照配置文件上下先后順序,優選prefer。
    
2   時鍾跳變時處理機制
2.1 有多個server,正在對時的server跳變超過1000S(默認), 會取消從該server對時,並嘗試切換至其他可用時鍾源。
    # 例如:上級時鍾源跳變后,示例環境會切換至本地時鍾源。查詢狀態如下: 
    svr-0:/opt/***/bin # service ntp status
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
     10.148.146.28   LOCAL(0)        11 u   50   64  377    0.442  -424067 320564.
    *LOCAL(0)        .LOCL.           5 l   18   64  377    0.000    0.000   0.001
    # 對應/var/log/ntp日志記錄:synchronized to LOCAL(0), stratum 5 
    
2.2 取消從上級server對時后,如果沒有其他可用(含本地)的時鍾源,則本機ntp服務%dead%。
    # 查詢狀態如下:
    svr-0:/opt/***/bin # ntpq -np
    ntpq: read:Connection refused
    svr-0:/opt/***/bin # service ntp status
    Checking for netword time protocol daemon (NTPD)           dead
    # 對應/var/log/ntp日志記錄:time correction of 334 seconds exceeds sanity limit (60); set clock manually to the correct UTC time.
    @@ 注意:該句日志也是我們上報告警與否的重要依據。
    
2.3 只有本地時鍾源,本地時鍾源跳變(date -s修改時間),不會使得本機ntp服務掛掉,狀態正常。
    # 對應/var/log/ntp日志會有記錄:kernel time sync status change 2001


 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM