自动更新服务器时间的最简单的方法是什么?

自动更新服务器时间的最简单的方法是什么?

在 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

相关内容