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 / 问题 / 1055736
Accepted
molik
molik
Asked: 2021-03-04 00:17:21 +0800 CST2021-03-04 00:17:21 +0800 CST 2021-03-04 00:17:21 +0800 CST

ntpd:权限被拒绝写入 /var/log/ntpstats/(statsdir 目录)

  • 772

我在 Ubuntu 20.04 LTS 上运行 NTP 服务器。服务器工作正常,客户端正确轮询服务器。但是当我想记录统计信息时,我不断收到权限错误。

我试图在 ntp.conf 中包含以下几行:

statistics rawstats
statsdir /var/log/ntpstats/
filegen rawstats file raw type day link enable

看的时候systemctl ntp status:

mars 05 09:08:48 RD-NTP ntpd[3534] : can't open /var/log/ntpstats/raw.20210305: Permission denied
mars 05 09:08:50 RD-NTP ntpd[3534] : can't open /var/log/ntpstats/raw.20210305: Permission denied
mars 05 09:08:52 RD-NTP ntpd[3534] : can't open /var/log/ntpstats/raw.20210305: Permission denied
mars 05 09:08:54 RD-NTP ntpd[3534] : can't open /var/log/ntpstats/raw.20210305: Permission denied

但对我来说,该目录具有正确的权限ls -al:

drwxr-xr-x 2 ntp ntp 4096 april 2 2020 .

在选择默认文件夹之前,我尝试使用我创建的一个并使用此命令在权限中添加 ntp : chmod ntp:ntp /home/ubuntu/ntpstats/,它不起作用所以我切换到这个,也不起作用。

你知道为什么 ntpd 一直出错,即使 ntp 在文件夹上占了上风吗?

ubuntu ntp statistics
  • 2 2 个回答
  • 1279 Views

2 个回答

  • Voted
  1. Best Answer
    Paul Gear
    2021-03-04T02:12:52+08:002021-03-04T02:12:52+08:00

    很可能导致您的权限问题的不是权限位,而是 AppArmor。ntpdUbuntu 20.04 ( ) 上的默认 AppArmor 配置文件/etc/apparmor.d/usr.sbin.ntpd包含:

    ...
    /var/log/ntp w,
    /var/log/ntp.log w,
    /var/log/ntpd w,
    /var/log/ntpstats/clockstats* rwl,
    /var/log/ntpstats/loopstats*  rwl,
    /var/log/ntpstats/peerstats*  rwl,
    /var/log/ntpstats/protostats* rwl,
    /var/log/ntpstats/rawstats*   rwl,
    /var/log/ntpstats/sysstats*   rwl,
    ...
    

    请注意,与正在生成的文件名相比,它所期望的文件名不匹配ntpd。如果您将 AppArmor 配置文件行引用rawstats更改为:

    /var/log/ntpstats/raw*   rwl,
    

    并使用 重新加载 AppArmor systemctl reload apparmor,您的统计数据记录可能会起作用。

    还要注意loopstats和peerstats比 . 更有可能有助于诊断 NTP 问题rawstats。(有关此内容的更多信息,请参见http://doc.ntp.org/current-stable/monopt.html#types。)就个人而言,我认为如果您要费心记录 rawstats,最好只捕获每个网络上的NTP数据包并使用wireshark或类似的协议分析器对其进行处理。

    • 2
  2. Phill W.
    2021-03-04T01:11:46+08:002021-03-04T01:11:46+08:00

    文件本身呢?那已经存在了吗?

    试试这些:

    ls -ld /var/log/ntpstats
    ls -ld /var/log/ntpstats/raw.20210305
    

    chmod ntp:ntp /home/ubuntu/ntpstats/

    小心!
    chown更改所有权,而不是权限。
    chmod更改权限。

    我建议你需要很好地掌握这两个概念,否则你可能会把你的 Linux 机器弄得一团糟。

    • 0

相关问题

  • 无法通过 Ubuntu VPN 访问外部网络

  • ubuntu apt-get upgrade - 如何在 shell 中单击确定?

  • VirtualBox 上 Ubuntu 的访客优化技巧 [关闭]

  • 外部硬盘上的 virtualbox 虚拟硬盘驱动器(Vista 主机上的 ubuntu 客户机)

  • 如何在 Ubuntu 上挂载 LVM 分区?

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