0%

记一次奇怪 systemd-resolved 出错

问题

systemd-resolved

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
❯ systemctl status systemd-resolved.service
● systemd-resolved.service - Network Name Resolution
Loaded: loaded (/lib/systemd/system/systemd-resolved.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2021-11-01 16:38:05 CST; 23h ago
Docs: man:systemd-resolved.service(8)
https://www.freedesktop.org/wiki/Software/systemd/resolved
https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients
Process: 2515466 ExecStart=/lib/systemd/systemd-resolved (code=exited, status=226/NAMESPACE)
Main PID: 2515466 (code=exited, status=226/NAMESPACE)

Nov 01 16:38:04 hkt.mcmc.live systemd[1]: Stopped Network Name Resolution.
Nov 01 16:38:04 hkt.mcmc.live systemd[1]: Starting Network Name Resolution...
Nov 01 16:38:05 hkt.mcmc.live systemd[1]: systemd-resolved.service: Main process exited, code=exited, status=226/NAMESPACE
Nov 01 16:38:05 hkt.mcmc.live systemd[1]: systemd-resolved.service: Failed with result 'exit-code'.
Nov 01 16:38:05 hkt.mcmc.live systemd[1]: Failed to start Network Name Resolution.
Nov 01 16:38:05 hkt.mcmc.live systemd[1]: systemd-resolved.service: Scheduled restart job, restart counter is at 5.
Nov 01 16:38:05 hkt.mcmc.live systemd[1]: Stopped Network Name Resolution.
Nov 01 16:38:05 hkt.mcmc.live systemd[1]: systemd-resolved.service: Start request repeated too quickly.
Nov 01 16:38:05 hkt.mcmc.live systemd[1]: systemd-resolved.service: Failed with result 'exit-code'.
Nov 01 16:38:05 hkt.mcmc.live systemd[1]: Failed to start Network Name Resolution.

apt update

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
❯ apt update
Hit:1 http://mirrors.tencentyun.com/ubuntu focal InRelease
Hit:2 http://mirrors.tencentyun.com/ubuntu focal-security InRelease
Hit:3 http://mirrors.tencentyun.com/ubuntu focal-updates InRelease
0% [Connecting to ppa.launchpad.net (91.189.95.85)]gpgv: Signature made Fri Apr 24 01:34:17 2020 CST
gpgv: using RSA key 3B4FE6ACC0B21F32
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>"
gpgv: Signature made Fri Apr 24 01:34:17 2020 CST
gpgv: using RSA key 871920D1991BC93C
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2018) <ftpmaster@ubuntu.com>"
/usr/bin/apt-key: 57: cannot create /dev/null: Permission denied
0% [Connecting to ppa.launchpad.net (91.189.95.85)]gpgv: Signature made Tue Nov 2 05:30:01 2021 CST
gpgv: using RSA key 3B4FE6ACC0B21F32
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>"
gpgv: Signature made Tue Nov 2 05:30:01 2021 CST
gpgv: using RSA key 871920D1991BC93C
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2018) <ftpmaster@ubuntu.com>"
/usr/bin/apt-key: 57: cannot create /dev/null: Permission denied
0% [Waiting for headers]gpgv: Signature made Tue Nov 2 05:30:35 2021 CST
gpgv: using RSA key 3B4FE6ACC0B21F32
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>"
gpgv: Signature made Tue Nov 2 05:30:35 2021 CST
gpgv: using RSA key 871920D1991BC93C
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2018) <ftpmaster@ubuntu.com>"
/usr/bin/apt-key: 57: cannot create /dev/null: Permission denied
Hit:4 http://ppa.launchpad.net/alessandro-strada/ppa/ubuntu focal InRelease
0% [Working]gpgv: Signature made Sun Oct 24 03:17:20 2021 CST
gpgv: using RSA key 9EA4D6FCA5D37A5D1CA9C09AAD5F235DF639B041
gpgv: Good signature from "Launchpad PPA for Alessandro Strada"
/usr/bin/apt-key: 57: cannot create /dev/null: Permission denied
Reading package lists... Done

解决

apt update

  1. cat /lib/systemd/system/systemd-resolved.service
  2. 直接执行启动解析服务,没有任何错误,应该是上面修复造成的影响 /lib/systemd/systemd-resolved
  3. 直接重启服务,启动成功
  • 所以问题就很明显了,systemd-resolved 启动需要用到 /dev/null 设备,然而该设备出了问题,导致启动失败
方法一
  • 重启就好了,重启后该设备会自动重新创建
方法二
  • 手动重新创建该设备
1
rm -f /dev/null; mknod -m 666 /dev/null c 1 3
-------------本文结束再接再厉-------------

本文标题:记一次奇怪 systemd-resolved 出错

文章作者:IITII

发布时间:2021年11月02日 - 17:11

最后更新:2021年11月02日 - 17:11

原始链接:https://iitii.github.io/2021/11/02/1/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。