NTP 不更新 CentOS 中的服务器时间

Ori*_*ion 3 linux ntp

我为 arm 编译了 ntp 我的 NTP 客户端没有更新我提到的帖子“为什么 ntpd 没有更新我的服务器上的时间?(7)”的任何服务器的时间,但没有任何效果......这是输出ntpq -pn

[Tue May 15 13:18:26 root@Unknown:bin]$./ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 125.62.193.121  .INIT.          16 u    -   16    0    0.000    0.000   0.000
Run Code Online (Sandbox Code Playgroud)

我了解到 refid 不应该是“.INIT”并且延迟、偏移、抖动值不应该是 0

关于查看 ntpd 的日志

[Tue May 15 13:19:08 root@Unknown:bin]$tail -f ntp.log
15 May 12:29:35 ntpd[18175]: proto: precision = 1000.000 usec
15 May 12:29:35 ntpd[18175]: ntp_io: estimated max descriptors: 1024, initial socket boundary:
15 May 12:29:35 ntpd[18175]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
15 May 12:29:35 ntpd[18175]: Listen normally on 1 lo 127.0.0.1 UDP 123
15 May 12:29:35 ntpd[18175]: Listen normally on 2 eth1 173.39.19.72 UDP 123
15 May 12:29:35 ntpd[18175]: peers refreshed
15 May 12:29:35 ntpd[18175]: Listening on routing socket on fd #19 for interface updates
Run Code Online (Sandbox Code Playgroud)

附带说明 - ntpupdate -u ntp.ubuntu.com 有效,但 ntpd 无效。我的 ntp.conf 只包含一行

server 91.189.94.4 minpoll 4 maxpoll 4
Run Code Online (Sandbox Code Playgroud)

上面的 IP 用于 ntp.ubuntu.com。


[Fri May 18 15:12:26 root@Unknown:~]$ping pool.ntp.org
PING pool.ntp.org (202.71.140.36): 56 data bytes
64 bytes from 202.71.140.36: seq=0 ttl=53 time=40.000 ms
64 bytes from 202.71.140.36: seq=1 ttl=53 time=39.000 ms
64 bytes from 202.71.140.36: seq=2 ttl=53 time=39.000 ms
64 bytes from 202.71.140.36: seq=3 ttl=53 time=39.000 ms
Run Code Online (Sandbox Code Playgroud)

Ping 有效,但服务器永远不会更新它的时间

Chr*_*s S 6

您的 ntpd 认为远程系统是第 16 层(意味着它的时间可能最不可靠)。大多数 ntp 客户端不会与这样的系统同步。我强烈建议pool.ntp.org 按照他们的说明使用。

他们的示例ntp.conf文件:

driftfile /var/lib/ntp/ntp.drift

server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server 3.pool.ntp.org
Run Code Online (Sandbox Code Playgroud)

此外,除非您的系统因某些疯狂的需求而无法支持 DNS 解析,否则您永远不应该在配置文件中使用 IP。

更新:
NTP 池项目试图对它应该返回给您的时间服务器进行半智能猜测。但是您通常应该通过在主机名中使用国家/地区代码来指定您希望服务器来自的国家/地区。对于印度来说,它将是:

server 0.in.pool.ntp.org
server 1.in.pool.ntp.org
server 2.in.pool.ntp.org
server 3.in.pool.ntp.org
Run Code Online (Sandbox Code Playgroud)

相同的漂移、日志记录和其他选项仍然适用。

  • `reach` 列中的 `0` 表示您的 NTP 无法联系在 `125.62.193.121` 上运行的 NTP。按照 Chris S 的建议修改配置。 (3认同)