AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[ntpd](server)

Martin Hope
vivek
Asked: 2021-07-24 20:27:20 +0800 CST

如果网络连接稍晚一点,ntpd 不会同步时钟

  • 0

在我们的生产环境中,我面临着 ntpd 的问题。我正在为我们的生产盒启用 NTP 功能并观察一个问题。

我们在盒子的初始化过程中启动 ntpd 守护进程。在那段时间互联网连接不存在。下面是我的小ntp.conf文件

driftfile  /etc/ntp.drift
logconfig =syncstatus
server pool.ntp.org iburst

一旦接口出现,我们的盒子就可以很晚地获得互联网连接。那个时候我看到 ntpd 没有同步时钟。当我这样做时ntpq -c as,我得到了no association id's found。我确实等了将近 30 分钟,但还是得到了no association id's found

我必须重新启动ntpd。重启后,ntpd 同步时钟,一切正常。但是,如果我重新启动我的盒子,那么同样的问题就会发生。再次,我必须重新启动 ntpd,一旦盒子出现并且可以访问互联网。

有没有人遇到过类似的问题?

我应该延迟 ntpd 的启动直到时间界面出现吗?

更新

我做了一些更多的实验,并用这个更改替换server pool.ntp.org iburst了pool pool.ntp.org iburstntpd 自动同步时钟。我不必重新启动 ntpd。所以这里对我提出了另一个问题。

当我替换为 时发生server了pool什么?

我应该总是使用pool关键字而不是server?

我应该什么时候使用pool,什么时候应该使用server?

我做了一些研究,发现 pool is the same as server, except it resolves one name into several addresses and uses them all 如果他们在做同样的事情,那为什么server pool.ntp.org iburst不为我工作但pool pool.ntp.org iburst工作。

更新

正如建议的那样,我已经使用pool了,server但我的时钟仍然无法在启动时同步。以前no association id's found来过,但在使用池后它正在显示列表。

GW:/admin# ntpq -c lpeer
     remote           refid      st t when poll reach   delay    offset  jitter
===================================================================== =========
 time.google.com .POOL.          16 p    -   64    0    0.000   +0.000   0.002

GW:/admin# ntpq -np
      remote           refid      st t when poll reach   delay   offset  jitter

 time.google.com .POOL.          16 p    -   64    0    0.000   +0.000   0.002

GW:/admin# ntpq -c as
ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 34173  8811   yes  none  none    reject    mobilize  1

GW:/admin# ntpq -c "rv 34173"
associd=34173 status=8811 conf, bcast, sel_reject, 1 event, mobilize,
srcadr=0.0.0.0, srcport=0, srchost="time.google.com", dstadr=0.0.0.0,
dstport=0, leap=11, stratum=16, precision=-19, rootdelay=0.000,
rootdisp=0.000, refid=POOL, reftime=(no time), rec=(no time), reach=000,
unreach=0, hmode=3, pmode=0, hpoll=6, ppoll=10, headway=0,
flash=1400 peer_dist, peer_unreach, keyid=0, offset=+0.000, delay=0.000,
dispersion=16000.000, jitter=0.002,
filtdelay=     0.00    0.00    0.00    0.00    0.00    0.00      0.00    0.00,
filtoffset=   +0.00   +0.00   +0.00   +0.00   +0.00   +0.00   +0.00   +0.00,
filtdisp=   16000.0 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0

我看到闪存状态为1400。1400我无法1400在 ntp 文档中找到闪存状态是什么意思。

更新

它开始工作了。我替换iburst为minpoll 3 maxpoll 4,之后它正在重新启动。我用过这样的游泳池 pool pool.ntp.org minpoll 3 maxpoll 4。我不确定这种变化有什么不同。

我还读到我们应该避免使用 minpoll 和 maxpoll。 Too frequent for a sustained period and public NTP services may block you. ntpd is already good at dynamically selecting the pool interval.

不管怎样,谢谢大家帮助我。

ntp ntpd conf
  • 1 个回答
  • 289 Views
Martin Hope
Alexis Wilke
Asked: 2021-07-22 14:13:34 +0800 CST

VirtualBox Linux 服务器中的 NTP 同步故障排除

  • 1

我有一个相当简单的设置,我有两台计算机:

计算机 A. 具有正常的 NTP 设置并使用标准 Internet 资源(根据 Ubuntu)来确定时间。它还允许查询 IP 10.0.2.0/24:

restrict 10.0.2.0 mask 255.255.255.0 nomodify notrap

计算机 B. 具有正常的 NTP 设置,但所有源都更改为使用10.0.2.1(即计算机 A)。

有时,计算机 A 会从其中一个源获得死亡之吻信号。结果,它完全杀死了计算机 B 的 NTP(即看起来像是直接传输 KoD)。

有没有办法知道 NTP 服务器的状态是否只是发送 KoD 消息?(还有,我该如何摆脱这种情况?当我查看时,日志中显示的所有IP地址都没有被服务器使用?!所以我不明白为什么它坚持将KoD发送给它的客户端) .


到目前为止,我发现了两件事:

  1. ntpq

    我可以ntpq这样跑:

     ntpq -pn
    

    当 NTP 服务器工作时,我可以在计算机满意的 IP 地址前看到一个星号。就我而言,所有状态标志(第一列、、、、+等-)都消失了。据我所知,这意味着 NTP 服务不满意并且没有执行同步。*#

    这是一个仍然有效的示例(即第一列中有标志):

          remote           refid      st t when poll reach   delay   offset  jitter
     ==============================================================================
      10.0.2.255      .BCST.          16 B    -   64    0    0.000    0.000   0.000
     #51.77.203.211   134.59.1.5       3 u    4   64    1  171.248  -743.64 691.917
     +72.5.72.15      216.218.254.202  2 u    2   64    1   19.223  -778.34 686.200
     +159.69.25.180   192.53.103.103   2 u    3   64    1  237.733  -775.41 701.376
     +173.0.48.220    43.77.130.254    2 u    2   64    1   35.489  -778.85 669.187
      38.229.56.9     172.16.21.35     2 u   31   64    1  153.976  -268.90 122.557
     +137.190.2.4     .PPS.            1 u   31   64    1   93.797  -253.69 116.289
     +150.136.0.232   185.125.206.71   3 u   35   64    1   95.667  -178.19 114.912
      94.154.96.7     194.29.130.252   2 u   31   64    1  237.560  -231.88 107.230
     +162.159.200.123 10.4.1.175       3 u   34   64    1   16.246  -199.68 115.561
     *216.218.254.202 .CDMA.           1 u   35   64    1   52.906  -193.84 131.148
      91.189.91.157   132.163.96.1     2 u   45   64    1   87.772   -5.716   0.000
     +204.2.134.163   44.24.199.34     3 u   34   64    1   16.711  -199.12 116.777
     +74.6.168.73     208.71.46.33     2 u   35   64    1   69.772  -189.21 128.119
      91.189.89.199   17.253.34.123    2 u   45   64    1  165.471   -3.708   0.000
     +216.229.0.49    216.218.192.202  2 u   35   64    1   71.437  -178.94  97.505
      91.189.89.198   17.253.34.123    2 u   44   64    1  172.852  -17.899   0.000
    
  2. ntpdate -q <ip>

    该ntpdate命令实际上会告诉我 NTP 是否正在接受数据包。这是因为如果不是,它会给出错误消息:

     $ sudo ntpdate -q 10.0.2.1
     server 10.0.2.1, stratum 4, offset 5.194725, delay 0.02652
     21 Jul 15:22:48 ntpdate[13086]: no server suitable for synchronization found
    

    过了一会儿,当我的主服务器失去了*它首先乐意与之同步的一台服务器上的状态时,就会发生这种情况......

现在......我仍然需要了解我必须做些什么来解决这个问题......


这可能会有所帮助,以下是有关从完全重新启动重新启动的日志:

Jul 21 18:29:13 vm-ve-ctl kernel: [  434.275481] audit: type=1400 audit(1626917353.636:43): apparmor="DENIED" operation="open" profile="/usr/sbin/ntp
d" name="/snap/bin/" pid=3896 comm="ntpd" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Jul 21 18:29:13 vm-ve-ctl ntpd[3896]: ntpd [email protected] (1): Starting
Jul 21 18:29:13 vm-ve-ctl ntpd[3896]: Command line: /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 126:129
Jul 21 18:29:13 vm-ve-ctl ntpd[3901]: proto: precision = 0.190 usec (-22)
Jul 21 18:29:13 vm-ve-ctl ntpd[3901]: Cannot open logfile /var/log/ntp.log: Permission denied
Jul 21 18:29:13 vm-ve-ctl kernel: [  434.291490] audit: type=1400 audit(1626917353.652:44): apparmor="DENIED" operation="capable" profile="/usr/sbin/
ntpd" pid=3901 comm="ntpd" capability=1  capname="dac_override"
Jul 21 18:29:13 vm-ve-ctl ntpd[3901]: leapsecond file ('/usr/share/zoneinfo/leap-seconds.list'): good hash signature
Jul 21 18:29:13 vm-ve-ctl ntpd[3901]: leapsecond file ('/usr/share/zoneinfo/leap-seconds.list'): loaded, expire=2021-12-28T00:00:00Z last=2017-01-01T
00:00:00Z ofs=37
Jul 21 18:29:13 vm-ve-ctl ntpd[3901]: Listen and drop on 0 v6wildcard [::]:123
Jul 21 18:29:13 vm-ve-ctl ntpd[3901]: Listen and drop on 1 v4wildcard 0.0.0.0:123
Jul 21 18:29:13 vm-ve-ctl ntpd[3901]: Listen normally on 2 lo 127.0.0.1:123
Jul 21 18:29:13 vm-ve-ctl ntpd[3901]: Listen normally on 3 enp0s3 192.168.2.120:123
Jul 21 18:29:13 vm-ve-ctl ntpd[3901]: Listen normally on 4 enp0s8 10.0.2.1:123
Jul 21 18:29:13 vm-ve-ctl ntpd[3901]: Listen normally on 5 lo [::1]:123
Jul 21 18:29:13 vm-ve-ctl ntpd[3901]: Listen normally on 6 enp0s3 [fe80::a00:27ff:fe25:38ff%2]:123
Jul 21 18:29:13 vm-ve-ctl ntpd[3901]: Listen normally on 7 enp0s8 [fe80::a00:27ff:fe35:c30b%3]:123
Jul 21 18:29:13 vm-ve-ctl ntpd[3901]: Listening on routing socket on fd #24 for interface updates
Jul 21 18:29:14 vm-ve-ctl ntpd[3901]: Soliciting pool server 51.77.203.211
Jul 21 18:29:15 vm-ve-ctl ntpd[3901]: Soliciting pool server 159.69.25.180
Jul 21 18:29:15 vm-ve-ctl ntpd[3901]: Soliciting pool server 72.5.72.15
Jul 21 18:29:16 vm-ve-ctl ntpd[3901]: Soliciting pool server 198.251.86.68
Jul 21 18:29:16 vm-ve-ctl ntpd[3901]: Soliciting pool server 173.0.48.220
Jul 21 18:29:16 vm-ve-ctl ntpd[3901]: Soliciting pool server 38.229.56.9
Jul 21 18:29:17 vm-ve-ctl ntpd[3901]: Soliciting pool server 150.136.0.232
Jul 21 18:29:17 vm-ve-ctl ntpd[3901]: Soliciting pool server 94.154.96.7
Jul 21 18:29:17 vm-ve-ctl ntpd[3901]: Soliciting pool server 137.190.2.4
Jul 21 18:29:18 vm-ve-ctl ntpd[3901]: Soliciting pool server 162.159.200.123
Jul 21 18:29:18 vm-ve-ctl ntpd[3901]: Soliciting pool server 216.218.254.202
Jul 21 18:29:18 vm-ve-ctl ntpd[3901]: Soliciting pool server 91.189.91.157
Jul 21 18:29:19 vm-ve-ctl ntpd[3901]: Soliciting pool server 91.189.89.199
Jul 21 18:29:19 vm-ve-ctl ntpd[3901]: Soliciting pool server 74.6.168.73
Jul 21 18:29:19 vm-ve-ctl ntpd[3901]: Soliciting pool server 204.2.134.163
Jul 21 18:29:20 vm-ve-ctl ntpd[3901]: Soliciting pool server 91.189.89.198
Jul 21 18:29:20 vm-ve-ctl ntpd[3901]: Soliciting pool server 216.229.0.49
Jul 21 18:29:20 vm-ve-ctl ntpd[3901]: Soliciting pool server 2604:ed40:1000:1711:d862:f5ff:fe4e:41c4
Jul 21 18:29:21 vm-ve-ctl ntpd[3901]: receive: Unexpected origin timestamp 0xe4a34871.ac57f05d does not match aorg 0000000000.00000000 from [email protected] xmt 0xe4a34871.65648c54

我不知道它什么时候开始变坏。我还看到了以下我认为可能与它有关的内容(即,当这种情况发生时,相应的 IP 将从列表中删除!),但现在已经很糟糕了,我上次运行时没有发生这样的错误。

Jul 21 18:08:57 vm-ve-ctl ntpd[9764]: 92.243.6.5 local addr 192.168.2.120 -> <null>

注意:192.168.2.120 是故障计算机的 IP。它是一个虚拟盒子。它已经工作了几个月......不过,也许发生了一些变化,这让它不开心。

我发现这篇关于消息问题的... -> <null>帖子。但是,我认为我们在 Ubuntu 18.04 上有一个更新的版本:

SUSE 最低推荐版本:ntp-4.2.8p7-11.1
Ubuntu 18.04 版本:1:4.2.8p10+dfsg-5ubuntu7.3


以防万一,我尝试将 VM 连接到主机,但仍然会出现巨大的偏移和抖动。有什么可以改变的?!

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 10.0.2.10       .POOL.          16 p    -   64    0    0.000    0.000   0.000
 10.0.2.10       132.163.97.6     2 u   54   64    3    0.457  -5254.2 3917.68

正如 Paul Gear 所问的,这里是 ntpq 的输出以及其他详细信息:

$ ntpq -ncrv
associd=0 status=0028 leap_none, sync_unspec, 2 events, no_sys_peer,
version="ntpd [email protected] (1)", processor="x86_64",
system="Linux/4.15.0-151-generic", leap=00, stratum=4, precision=-23,
rootdelay=17.930, rootdisp=5019.260, refid=173.255.215.209,
reftime=e4a44f7a.1c2ec778  Thu, Jul 22 2021 13:11:38.110,
clock=e4a45030.c8a4b259  Thu, Jul 22 2021 13:14:40.783, peer=0, tc=6,
mintc=3, offset=-109.527915, frequency=-1.707, sys_jitter=0.000000,
clk_jitter=38.724, clk_wander=0.000, tai=37, leapsec=201701010000,
expire=202112280000

以下是可用时钟列表和当前使用的时钟:

$ grep . /sys/devices/system/clocksource/clocksource*/[ac]*clocksource
/sys/devices/system/clocksource/clocksource0/available_clocksource:kvm-clock tsc acpi_pm 
/sys/devices/system/clocksource/clocksource0/current_clocksource:kvm-clock

最后,dmesg关于时钟源选择过程的输出:

$ dmesg | grep clocksource
[    0.000000] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns
[    0.000000] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645519600211568 ns
[    0.283117] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    1.161844] clocksource: Switched to clocksource kvm-clock
[    1.208316] clocksource: acpi_pm: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 2085701024 ns
[    2.329228] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x1db81a3240f, max_idle_ns: 440795250379 ns
ntp ntpd ubuntu-18.04
  • 2 个回答
  • 744 Views
Martin Hope
vivek
Asked: 2021-07-17 08:27:28 +0800 CST

如果我们在 ntp.conf 文件中有多个服务器,则 ntpd 守护进程更喜欢哪个服务器进行时间同步

  • 0

我读到ntp使用所有服务器进行时间同步。它给了我一个问题。假设我在ntp.conf文件中有多个服务器,并且时间间隔也超过 1 天。我还没有在ntp.conf文件中指定首选关键字。

server.1 <ip>
server.2 <ip>
server.3 <ip>
server.4 <ip> 

如果我ntpd使用-g选项运行,那么ntp守护程序将更喜欢哪个服务器来填补大的时间间隔?

ntp ntpd
  • 1 个回答
  • 295 Views
Martin Hope
Tombart
Asked: 2021-01-07 15:08:12 +0800 CST

ntpd 无法同步 TIME_ERROR: 0x41: 时钟未同步

  • 0

在 Debian 10 上,ntpd [email protected]无法同步并出现以下错误:

kernel reports TIME_ERROR: 0x41: Clock Unsynchronize

这是ntp.conf:

disable monitor

statsdir /var/log/ntpstats

restrict -4 default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1

server 0.us.pool.ntp.org iburst
server 1.us.pool.ntp.org iburst
server 2.us.pool.ntp.org iburst
server 3.us.pool.ntp.org iburst

server   127.127.1.0
fudge    127.127.1.0 stratum 10
restrict 127.127.1.0

driftfile /var/lib/ntp/drift

ntpq -c sysinfo:

associd=0 status=0614 leap_none, sync_ntp, 1 event, freq_mode,
system peer:        50-205-57-38-static.hfc.comcastbusiness.net:123
system peer mode:   client
leap indicator:     00
stratum:            2
log2 precision:     -23
root delay:         70.634
root dispersion:    3.569
reference ID:       50.205.57.38
reference time:     e3a0c049.c39d770a  Wed, Jan  6 2021 23:03:37.764
system jitter:      0.723169
clock jitter:       1.177
clock wander:       0.000
broadcast delay:    -50.000
symm. auth. delay:  0.000

ntpq -c lpeers:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 LOCAL(0)        .LOCL.          10 l  286   64   20    0.000    0.000   0.000
*50-205-57-38-st .GPS.            1 u   19   64   37   70.631    1.618   1.843
-ns1.backplanedn 173.162.192.156  2 u   14   64   37   84.235   -1.575   2.852
+c-73-239-136-18 74.6.168.73      3 u   11   64   37   48.606    1.598   2.522
+time-d.bbnx.net 252.74.143.178   2 u   14   64   37   92.632    0.623   0.799

timedatectl:

               Local time: Wed 2021-01-06 23:06:44 UTC
           Universal time: Wed 2021-01-06 23:06:44 UTC
                 RTC time: Wed 2021-01-06 23:06:44
                Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no

知道有什么问题吗?

ntp ntpd
  • 1 个回答
  • 16045 Views
Martin Hope
Zumo de Vidrio
Asked: 2020-11-27 01:14:56 +0800 CST

NTP 始终在本地同步

  • 0

我有一个具有以下 NTP 配置的 Ubuntu 16.04:

driftfile /var/lib/ntp/drift

restrict -4 default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1 nomodify notrap
restrict 10.0.200.15 mask 255.255.255.0 nomodify notrap

server 127.127.1.0
fudge 127.127.1.0 stratum 10

server 0.ntp.pool.org iburst prefer minpoll 4 maxpoll 7
server 1.ntp.pool.org iburst prefer minpoll 4 maxpoll 7
server 2.ntp.pool.org iburst prefer minpoll 4 maxpoll 7
tinker panic 0

restrict 127.0.0.1
restrict -6 ::1

但它总是与 localhost 同步(我认为是因为层值较低):

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 127.127.1.0     .LOCL.          10 l  16h   64    0    0.000    0.000   0.000
 64.99.80.121    .STEP.          16 u    -  128    0    0.000    0.000   0.000

但是我希望它与外部 NTP 同步ntp.pool.org

我已将 ubuntu ntp 服务器添加到 ntp.conf 文件中:

server ntp.ubuntu.com iburst prefer minpoll 4 maxpoll 7

现在我看到它有一个第 2 层,并且 ntp 能够与之同步:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 127.127.1.0     .LOCL.          10 l  16h   64    0    0.000    0.000   0.000
 64.99.80.121    .STEP.          16 u    -  128    0    0.000    0.000   0.000
*91.189.91.157   194.58.200.20    2 u   15  128  377   79.191    0.042   1.964

为ntptrace两台服务器提供超时:

$ ntptrace ntp.ubuntu.com
ntp.ubuntu.com: timed out, nothing received
***Request timed out
$ ntptrace ntp.pool.org
ntp.pool.org: timed out, nothing received
***Request timed out

我是否缺少一些只能与同步的配置ntp.pool.org?

我已经在这里检查了答案, 但我没有找到适合我的案例的答案


更新

此 VM 将充当其他 VM 的 ntp 服务器。

查询结果:

ntpdate -q ntp.pool.org
server 64.99.80.121, stratum 0, offset 0.000000, delay 0.00000
26 Nov 14:34:37 ntpdate[4577]: no server suitable for synchronization found
ntpdate -q ntp.ubuntu.com
server 91.189.94.4, stratum 2, offset 0.000290, delay 0.03615
server 91.189.89.199, stratum 2, offset 0.000654, delay 0.03668
server 91.189.89.198, stratum 2, offset -0.000251, delay 0.03674
server 91.189.91.157, stratum 2, offset 0.000159, delay 0.10548
26 Nov 14:36:15 ntpdate[4585]: adjust time server 91.189.94.4 offset 0.000290 sec

我在 ntp 文档中发现第 16 层表明 ntp 服务器存在一些问题。我们可以得出结论,这ntp.pool.org是行不通的吗?

linux ntp time-synchronization ntpd
  • 2 个回答
  • 572 Views
Martin Hope
Gerb
Asked: 2020-11-21 09:59:44 +0800 CST

虚拟机的 NodeClockNotSynchronising 上的 Prometheus 警报

  • 2

我正在尝试确定为什么此警报 ( NodeClockNotSynchronising) 会针对我已配置的少数 VM 触发。(不是全部,只是几个,这很奇怪)

根据导出的指标,我看到:

# HELP node_timex_sync_status Is clock synchronized to a reliable server (1 = yes, 0 = no).
# TYPE node_timex_sync_status gauge
node_timex_sync_status 0

我可以 ssh 进入其中一个虚拟机并且ntpd正在运行,并且date命令返回正确的时间。

因此,深入研究timex收集器文档和代码,这就是“失败”的原因:

    var syncStatus float64
    var divisor float64
    var timex = new(unix.Timex)

    status, err := unix.Adjtimex(timex)
    if err != nil {
        return fmt.Errorf("failed to retrieve adjtimex stats: %w", err)
    }

    if status == timeError {
        syncStatus = 0
    } else {
        syncStatus = 1
    }

由于 syncStatus 为 0,因此正在触发警报。深入研究adjtimex()系统调用的返回码:

#define TIME_ERROR        5        /* clock not synchronized */

为什么内核在运行并且时钟同步TIME_ERROR时会返回?ntpd任何帮助将不胜感激。

linux ntpd prometheus
  • 1 个回答
  • 3182 Views
Martin Hope
user630702
Asked: 2020-05-02 05:12:16 +0800 CST

NTP - NTP 会在多少延迟后选择池中的远程服务器?

  • 1

选定的服务器将由 指示*。但是,如果重新启动 ntp 服务,从池中选择对等点需要多长时间?

我正在尝试监视 NTP 服务器偏移量,但每次我重新启动服务时,选择过程都需要一段时间,并且想知道需要多长时间。

~$ ntpq -p
remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*time4.stupi.se  .PPS.            1 u    2  128  377    7.796   16.636   4.146
+213-21-116-142. 192.36.144.22    2 u   18   64  377    8.261   17.013   3.807
+ntp.xpd.se      192.36.144.22    2 u   38   64  377    8.855   20.929   2.537
+mail.joacimmeli 192.36.144.22    2 u   28   64  377    9.228   19.509  25.804
+juniperberry.ca 193.79.237.14    2 u   26   64  377   44.612   19.835   2.443
~$
ntp ntpd
  • 1 个回答
  • 366 Views
Martin Hope
user1828163
Asked: 2020-04-08 08:29:28 +0800 CST

我可以在 ntp 中同时使用池和服务器配置吗?

  • 0

对于 ntp 恶魔,如果我有这个配置会发生什么ntp.conf:

pool 0.pool.ntp.org burst iburst minpoll 4

server europe.pool.ntp.org

?

ntp 将如何配置?

我不知道有什么方法可以查询 ntp 的活动配置 - 以便知道哪个服务器或池,以及在给定时刻正在使用哪些选项。

ntp ntpd chrony conf
  • 2 个回答
  • 902 Views
Martin Hope
Andy
Asked: 2017-01-31 04:50:33 +0800 CST

尝试读取密钥文件时拒绝 NTP 服务器权限

  • 1

我正在尝试为我的内部网络上的主机设置一个 NTP 时间服务器以与之同步。

我需要使用授权才能符合 PCI 标准。

我使用 ntp-keygen -M 创建了一组密钥,并将以下代码段添加到服务器上的 /etc/ntp.conf 文件中。

enable auth
keys /etc/ntp.keys
trustedkey 1 7 17

我无法从客户端连接到服务器。当我在客户端上运行“ntpq -c as”时,我可以看到身份验证对我的服务器来说是“坏的”。我已将服务器上生成的密钥文件复制到客户端,并将受信任的密钥行也添加到客户端,如下所示:

server timeserver key 17
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
restrict 127.0.0.1
restrict ::1
keys /etc/ntp.keys
trustedkey 1 7 17

查看服务器日志,我可以看到在尝试读取文件时出现权限被拒绝错误,如下所示。

Jan 30 12:38:01 ip-10-0-1-103 systemd[1]: Starting LSB: Start NTP daemon...
Jan 30 12:38:01 ip-10-0-1-103 ntp[28084]:  * Starting NTP server ntpd
Jan 30 12:38:01 ip-10-0-1-103 ntpd[28094]: ntpd [email protected] Wed Oct  5 12:34:45 UTC 2016 (1): Starting
Jan 30 12:38:01 ip-10-0-1-103 ntpd[28094]: Command line: /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 112:116
Jan 30 12:38:01 ip-10-0-1-103 ntp[28084]:    ...done.
Jan 30 12:38:01 ip-10-0-1-103 systemd[1]: Started LSB: Start NTP daemon.
Jan 30 12:38:01 ip-10-0-1-103 ntpd[28096]: proto: precision = 0.182 usec (-22)
Jan 30 12:38:01 ip-10-0-1-103 ntpd[28096]: authreadkeys: file /etc/ntp.keys: Permission denied

我已经使用客户端机器上的 ntpdate 来设置服务器的日期,所以我非常有信心网络已经启动并正在运行。当我忙于设置它时,我实际上已经在两台服务器上禁用了 iptables。

服务器上的密钥文件是 600,如下所示:

-rw-------  1 root  root    1066 Jan 30 12:29 ntpkey_MD5key_timeserver.3694768152
lrwxrwxrwx  1 root  root      35 Jan 30 12:33 ntp.keys -> ntpkey_MD5key_timeserver.3694768152

我尝试将配置更改为指向实际文件而不是符号链接。

谁能帮我弄清楚系统日志中的错误是什么意思以及如何解决这个问题?

编辑:查看源代码,错误的“权限被拒绝”部分似乎来自操作系统。

ntp ntpd
  • 2 个回答
  • 2925 Views
Martin Hope
gmlox
Asked: 2016-11-12 11:43:06 +0800 CST

ntpq -p 不打印预期结果

  • 3

我在 debian 系统上设置 ntp 客户端功能时遇到了麻烦。

键入 ntpq -p 时,输出始终相同(输出中全为零且没有统计信息),如下所示:

sudo ntpq -p4
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 ntp2.mojsite.co .INIT.          16 -    - 1024    0    0.000    0.000   0.000
 panel1.web2.clu .INIT.          16 -    - 1024    0    0.000    0.000   0.000
 85.93.216.115   .INIT.          16 -    - 1024    0    0.000    0.000   0.000

正如您所看到的,范围、延迟、偏移和抖动都为零,而且这几天已经完全没有变化了。

我认为配置可能配置错误,这是我的 ntp.conf 文件:

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

#complete guide at:
#http://doc.ntp.org/4.1.0/ntpd.htm

#######################
# Monitoring Options  #
#######################
#Enable this if you want statistics to be logged.
statsdir /var/log/ntpstats/

#what to log (keyword "statistics")
#clockstats: for reference clock
#peerstats: for peers (remote ntp servers)
#loopstats: Record clock discipline loop statistics
#raw stats: for raw output
statistics loopstats peerstats clockstats rawstats

#type: generate files per day(day), per NTP process (pid), single file (none)
#per month (month) ... (year), or 24 hours of server operation (age)
#enable/disable output and
#link/nolink convenient to be able to access the current element of a file
#generation set by a fixed name

#recording of loop filter statistics information.
filegen loopstats file loopstats.log type day nolink enable

#recording of peer statistics information.
filegen peerstats file peerstats.log type day nolink enable

#recording of clock driver statistics information.
filegen clockstats file clockstats.log type day nolink enable

#recording of raw-timestamp statistics information.
filegen rawstats file rawstats.log type day nolink disable

###########################
# Reference Clock Options #
###########################
#server 127.127.t.u [prefer] [mode int] [minpoll int] [maxpoll int]
#fudge 127.127.t.u [time1 sec] [stratum int] [refid string] [mode int] [flag1 0|1] [flag2 0|1] [flag3 0|1] [flag4 0|1]

##########
# SERVER #
##########

#interface and ip setup, wildcard equals to 0.0.0.0
#This  command  controls  which  network  addresses ntpd opens,
#and whether input is dropped without processing.
#ignore: don't listen on this address
#drop: listen but drop
#listen: listen and accept
interface ignore ipv6
interface listen 127.0.0.1
interface ignore 192.168.1.100
interface ignore wildcard

##########
# CLIENT #
##########

#The various operating  modes are determined by the command keyword
#and the type of the required IP address.
# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example

# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>

#The iburst option is recommended, and sends a burst of packets only if
#it cannot obtain a connection with the first attempt.
#The burst option always does this, even on the first attempt,
#and should never be used without explicit permission
#and may result in blacklisting.

#this command mobilizes a persistent client mode association with the specified
#remote server or local radio clock.
#In this mode the local clock can synchronized to the remote server,
#but the remote server can never be synchronized to the local clock.

#The various operating modes are determined by the command keyword:
#server, peer, broadcast, manycastclient and the type of the required IP address.
server 1.hr.pool.ntp.org
server 0.europe.pool.ntp.org
server 3.europe.pool.ntp.org


##################
# Access Control #
##################

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.


# By default, exchange time with everybody, but don't allow configuration.
# restrict address mask / -4 -6 / default
# default: (everybody) equal to 0.0.0.0 255.255.255.255
# kod: If access is denied, send a kiss-of-death packet.
# let client know more about why is it blocked to fix the problem
# notrap: subsystem intended for remote event logging programs.
restrict -4 default kod notrap nomodify nopeer noquery noserve
restrict -6 default kod notrap nomodify nopeer noquery noserve

# Local users may interrogate the ntp server more closely.
# If ignoring interface on ipv6 run "ntpq -p -4" instead of just "-p" 
restrict 192.168.1.100      kod notrap nomodify nopeer noquery
restrict 127.0.0.1
restrict ::1

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 172.16.1.1 mask 255.255.255.0 notrust

#########################
# Miscellaneous Options #
#########################

#Provides a way to enable or disable various server options.
disable bclient     #if not specified default is: disable
disable calibrate   #disable
enable kernel       #enable
enable monitor      #enable
enable stats        #enable
enable ntp      #enable

#This command controls the amount and type of output written to the system
#syslog facility or the alternate logfile.
logconfig=syncall +clockall +sysall +peerall
logfile /var/log/ntp.log

#This command specifies the name of the file used to record
#the frequency offset of the local clock oscillator.
driftfile /var/lib/ntp/ntp.drift

# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
# broadcast 172.16.1.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient

设置了 NTP 防火墙规则,并记录了被阻止的连接,到目前为止没有任何内容被阻止。如果需要,我也会提供防火墙信息。

ntp ntpd
  • 2 个回答
  • 2088 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve