自動更新伺服器時間最簡單的方法是什麼?

自動更新伺服器時間最簡單的方法是什麼?

在 ubuntu 伺服器上,我通常的解決方案是安裝ntp軟體包並收工。這將安裝我需要的所有二進位文件,並在啟動時啟動 ntpd。

現在我正在開發一個伺服器配置,該配置將在許多伺服器上複製,並且通常需要盡可能精簡。我注意到在 ntpd 的預設配置中,可以向伺服器發出請求來詢問它現在是什麼時間。我不需要這個。我只需要伺服器自己的時間保持最新。

答案1

如上所述,ntpdate 作為 cron 作業不能取代 ntpd。

如果您要在許多伺服器上複製此配置,為什麼不直接註解掉 ntpd.conf 中服務時間的行然後重新打包,或者使用一些配置管理(例如 puppet)在作業系統開啟後將其推送到所有機器他們?

答案2

你可以嘗試 OpenBSD 實現,開放NTPD;儘管它因沒有完全實現 NTP 協議而受到批評(也許有些捏造),但它可能比官方 ntpd 更合適。

答案3

所以看來沒有ntpd就沒有辦法得到所有ntpd功能。所以我只是透過對 /etc/ntp.conf 進行這些修改來運行它。我還需要最後兩行嗎?

# Commenting out these lines that came standard
# # By default, exchange time with everybody, but don't allow configuration.                     
# restrict -4 default kod notrap nomodify nopeer noquery                                         
# restrict -6 default kod notrap nomodify nopeer noquery                                         

# Adding this one line
restrict default ignore

# Do I still need this? Does ntpd query itself when setting the local server's time?
# Local users may interrogate the ntp server more closely.                                       
restrict 127.0.0.1
restrict ::1

相關內容