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
    • 最新
    • 标签
主页 / unix / 问题 / 553930
Accepted
Gui13
Gui13
Asked: 2019-11-25 14:07:11 +0800 CST2019-11-25 14:07:11 +0800 CST 2019-11-25 14:07:11 +0800 CST

ntp 不能在只读的 Raspberry Pi 上工作

  • 772

我很难理解为什么 ntp(服务)不会在我的树莓派上正确设置时间。

我已将文件系统配置为只读,以保存我的 SD 卡,但它曾经可以工作,我似乎无法弄清楚为什么 ntp 现在不能工作。

在日志中,我收到了许多多行该消息:

ntpd[415]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized
ntpd[415]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized
ntpd[415]: error resolving pool 0.debian.pool.ntp.org: Temporary failure in name resolution (-3)
ntpd[415]: error resolving pool 1.debian.pool.ntp.org: Temporary failure in name resolution (-3)
ntpd[415]: error resolving pool 2.debian.pool.ntp.org: Temporary failure in name resolution (-3)
ntpd[415]: error resolving pool 3.debian.pool.ntp.org: Temporary failure in name resolution (-3)
ntpd[415]: error resolving pool 3.debian.pool.ntp.org: Temporary failure in name resolution (-3)
ntpd[415]: error resolving pool 2.debian.pool.ntp.org: Temporary failure in name resolution (-3)
ntpd[415]: error resolving pool 1.debian.pool.ntp.org: Temporary failure in name resolution (-3)
ntpd[415]: error resolving pool 0.debian.pool.ntp.org: Temporary failure in name resolution (-3)

我的 /etc/resolv.conf 看起来像这样:

# Generated by resolvconf
nameserver 8.8.8.8
nameserver 192.168.1.22

我可以在那个 RPi 上访问互联网,我可以 ping 池地址,我可以 ping google,我可以进行更新(在 rw 中重新安装后)...

我也可以手动发出 ntpdate 命令并且它可以工作!

$ sudo ntpdate -u 0.fr.pool.ntp.org 1.fr.pool.ntp.org
24 Nov 23:04:34 ntpdate[578]: step time server 129.250.35.250 offset 2418.621037 sec

所以,是的,我在这里拉头发。我不明白为什么 ntp 服务不起作用。我在互联网上大肆搜索,似乎没有人有这个特殊问题(都有一个故障的 dns,但我的工作正常)

我的只读设置如下:https ://hallard.me/raspberry-pi-read-only/

你们有什么想法吗?

ntp ntpd
  • 2 2 个回答
  • 3737 Views

2 个回答

  • Voted
  1. Best Answer
    Mark Rogers
    2020-03-25T02:01:35+08:002020-03-25T02:01:35+08:00

    我在面临类似问题时发现了这个问题。

    事实证明,该问题systemd的PrivateTmp功能在只读配置中不起作用。

    1. 一定要安装ntp和ntpdate
      sudo apt install -y ntp ntpdate
      
    2. 复制/lib/systemd/system/ntp.service到/etc/systemd/system/ntp.service

      cp /lib/systemd/system/ntp.service /etc/systemd/system/ntp.service
      
    3. 打开/etc/systemd/system/ntp.service并注释掉PrivateTmp=true。

      sudo nano /etc/systemd/system/ntp.service
      

    现在,它应该可以正常工作了!

    作为附加步骤,我现在也/var/lib/ntp按照此处tmpfs的建议进行了安装

    1. 打开/etc/fstab并tmpfs /var/lib/ntp tmpfs nosuid,nodev 0 0在文件末尾添加。
      sudo nano /etc/fstab
      

    在我的情况下,我发现这没有必要,但是对于在只读文件系统上运行还有其他见解。

    • 8
  2. obranco
    2021-09-08T14:59:11+08:002021-09-08T14:59:11+08:00

    马克罗杰的回答有效,但我认为用户覆盖更好:

    echo -e '[Service]\nPrivateTmp=false' > /etc/systemd/system/ntp.service.d/override.conf
    

    然后重新启动或者可能systemctl daemon-reload就足够了。

    • 3

相关问题

  • ntpstat 有效,但 ntpq 无效

  • 为 CentOS 7 寻找一个简单的 NTP 设置

  • 如何使用我的本地时间作为 `ntpd` 的唯一参考?

  • 系统时间在 Linux 机器上由于某种未知原因而自动更改

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