如何从权威时间服务器更新 CentOS 服务器的时间?

use*_*196 108 centos time-synchronization

我有 CentOS 机器,每次我注意到服务器在一段时间后丢失了正确的时间。手动设置正确的时间后,通常会延迟几分钟。是否有一种机制可以让我使用来自特定时间服务器的时间更新服务器?

eww*_*ite 124

使用ntp守护程序。运行yum install ntp并确保服务是通过ntsysv或启动的chkconfig ntpd on

要立即同步,请运行ntpdate time.apple.com(或类似的东西)。

  • @ewwhite 另一种解决方案是运行`ntpdate -b -u time.nist.gov`,它将尝试使用与ntpd 守护进程使用的端口不同的端口。 (8认同)
  • 尝试`/sbin/service ntpd stop`,然后是`ntpdate time.apple.com`,然后是`/sbin/service ntpd start` (3认同)

use*_*517 106

您需要安装和配置ntp。

yum install ntp
chkconfig ntpd on
ntpdate pool.ntp.org
service ntpd start
Run Code Online (Sandbox Code Playgroud)

应该设置并运行。你可能会发现ntp包已经安装好了,只需要配置一下。

  • 如果被更改的计算机不是虚拟机,则在 `ntpdate` 命令后使用 `hwclock -w`。这意味着下次计算机重新启动时,您的时钟不会比现在更不同步。 (3认同)

Tom*_*nor 14

是的。

NTP。

yum install ntp
chkconfig ntpd on
Run Code Online (Sandbox Code Playgroud)

做一个初始同步,与

ntpdate pool.ntp.org
Run Code Online (Sandbox Code Playgroud)

并使用以下命令启动时间守护程序:

/etc/init.d/ntpd start
Run Code Online (Sandbox Code Playgroud)