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
    • 最新
    • 标签
主页 / user-510512

ksonofre's questions

Martin Hope
ksonofre
Asked: 2022-01-18 06:18:28 +0800 CST

自动时间同步:`ntpdate` 有效,但 `chrony` 无效

  • 2

我的 Linux 服务器的时间同步有问题。这台机器和 NTP 服务器都位于(较小的)大学数据中心,因此是本地地址。

奇怪的是该ntpdate命令有效:

ntpdate -u 172.16.0.25

输出:

17 Jan 15:03:53 ntpdate[25993]: adjust time server 172.16.0.25 offset 0.036043 sec

但是,chronyd没有(它只是挂起):

chronyd -q 'server 172.16.0.25 iburst'

我正在尝试所有方法来设置自动时间同步,ntpd但没有成功,最后求助于chrony但仍然无法弄清楚。

这是发生了什么事ntpd。我使用https://vitux.com/how-to-setup-ntp-server-and-client-on-debian-10ntpdate上的说明进行安装。conf文件有一个命令

server 172.16.0.25 prefer iburst

而系统状态ntp报告

Jan 18 10:26:11 akulab1 ntpd[26957]: kernel reports active service TIME_ERROR: 0x41: Clock Unsynchronized

具有以下ntpq -p输出

HKS-SRV01.unica .LOCL.           1 u    9   64   15    0.557  2275.65   9.515 – 

但是,一段时间后,服务报告

Jan 18 10:31:01 akulab1 ntpd[26957]: ntpd exiting on signal 15 (Terminated)

因为 NTP 同步没有成功。但是,ntpdate -u 172.16.0.25 报告同步:18 Jan 10:33:13 ntpdate[26990]: step time server 172.16.0.25 offset 2.282101 sec(如果我没记错的话......) – ksonofre 7 分钟前

这是我的/etc/ntp.conf文件:

driftfile /var/lib/ntp/ntp.drift

leapfile /usr/share/zoneinfo/leap-seconds.list

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

server 172.16.0.25 prefer iburst

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

restrict 127.0.0.1
restrict ::1

restrict source notrap nomodify noquery

我再次重新启动了 NTP 服务:systemctl restart ntp

的输出ntpq -np如下:

root@akulab1:~# ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 172.16.0.25     .LOCL.           1 u   63   64  377    0.518  104.685  14.815

但是,服务 ( systemctl status ntp) 仍然报告:

Jan 18 11:04:10 akulab1 ntpd[27089]: kernel reports TIME_ERROR: 0x4041: Clock Unsynchronized

而且,在我设置timedatectl set-ntp trueNTP 服务后,它会简单地关闭,即报告不活动。

我再次重新启动了 ntpd 服务并且它处于活动状态。此外,我已经等了一个多小时进行同步,但它从来没有得到它(服务器地址前面没有星号或加号) - 这是输出ntpq -np:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 172.16.0.25     .LOCL.           1 u   61   64  377    0.588  269.847  14.797

此外,这是ntpdate -qu命令的输出:

18 Jan 13:57:44 ntpdate[1975]: no servers can be used, exiting

好的,上面的命令不完整,所以ntpdate -qu 172.16.0.25有以下输出:

server 172.16.0.25, stratum 1, offset 0.435131, delay 0.02621
18 Jan 14:51:56 ntpdate[6951]: adjust time server 172.16.0.25 offset 0.435131 sec

并ntpq -np给出以下内容:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 172.16.0.25     .LOCL.           1 u   17   64  377    0.554  436.092  14.279

解决方案在下面接受的答案中给出。我假设时间同步现在正在工作,但我仍然会跟踪时钟漂移并更新我的问题,如果它没有正确同步。


最终解决方案发布在这篇文章中:ntp server reachable but never select/set the time

linux time
  • 1 个回答
  • 817 Views

Sidebar

Stats

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

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve