
我想讓 Stratum 1 伺服器中的本地時鐘成為我的網路的網路時間源(我不想要帶有天線的 Stratum 0 伺服器)。我如何在網路中進行設定?是否有教學解釋如何使用網路時間協定並進行設定?到目前為止,我還沒有在谷歌上找到任何關於如何實現這一目標的資訊。我將衷心感謝您的幫助。
答案1
相對於現代設備所期望的精度而言,通用計算機中的時鐘是垃圾。未精確校準,伺服器的熱變化可能會導致漂移變更。因此它需要某種方法來更新,否則最終會變得不準確,在極端情況下會以分鐘為單位。有時只要時鐘一致就足夠了,但人們往往期望更好。
繼續進行實際配置。例如,在 Linux 上,chrony 很流行,並且具有手動設定時鐘和處理斷開連接的功能。從以下範例開始關於守時的 RHEL 文檔,並參考 chrony 手冊作為參考。
大多數時間伺服器至少具有網路存取、衛星導航天線或精確時鐘硬體之一。預設情況下,如果時間最終來自通過 NTP 的參考時鐘,則 chrony 將提供時間。將允許指令設定為您的網路並使用您的 NTP 伺服器。但是,如果您沒有這些,您仍然可以使用 local 指令來設定 chrony 服務時間。
如果這確實是一個沒有時間硬體的氣隙網絡,還可以啟用手動指令,這樣您就可以使用 手動告訴它時間chronyc settime
。
chrony.conf 包含這些內容,一些關於 NTP 伺服器可以使用的內容的評論,以及我喜歡 EL 預設配置的一些內容:
# chrony.conf that still serves time if not syncronized
# Options for time sources
# NTP appliance
# For example, sat nav modules are inexpensive
# Assuming it is available over IP, it is an NTP server
#server time.zone.example.net iburst
# Isolated computers need software updates too!
# If there is an update server on the local net via IP,
# it can serve NTP as well as patches
#server updateproxy.example.net iburst
# Public internet NTP
# Use if you actually have internet
# But no local time source somehow
#pool 2.pool.ntp.org iburst
# Pretend local clock is syncronized
# Enabling serving time
# Use a high stratum, as a lower priority over better clocks
local stratum 10
# Allow "chronyc settime"
# Run this with input time based on e.g. a watch or other clock
# Regularly and when the time is wrong
manual
# Allow clients to query this server
# Replace with your local net prefix
allow 2001:db8:2ea1::/48
### End source customization
### Begin other configuration
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
logdir /var/log/chrony
log measurements statistics tracking