无法让 systemd-networkd 成功启动

无法让 systemd-networkd 成功启动

我有一台具有六个网络接口的迷你电脑,运行带有内核 3.10 的 CentOS 7.2,并进行了最小安装。

我想将我的接口命名为 net0-net5。为此,我尝试遵循此处提到的建议:http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

上面的文章指出,为了重命名我的接口,我需要创建 .link 文件并将其放在 /etc/systemd/network 中。这是人们需要按照 systemd-networkd 重命名其网络接口的新方法。

然而我发现,systemd-networkd 服务无法启动,并且如果没有运行此服务,我认为我根本无法命名我的接口。

请参阅以下内容:

systemctl --failed -l
  UNIT                     LOAD   ACTIVE SUB    DESCRIPTION
<E2><97><8F> systemd-networkd.service loaded failed failed Network Service
<E2><97><8F> systemd-networkd.socket  loaded failed failed networkd rtnetlink so

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

2 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.


systemctl  status systemd-networkd -l
��● systemd-networkd.service - Network Service
   Loaded: loaded (/usr/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
   Active: failed (Result: start-limit) since Tue 2011-05-10 01:45:45 UTC; 32min ago
     Docs: man:systemd-networkd.service(8)
  Process: 317 ExecStart=/usr/lib/systemd/systemd-networkd (code=exited, status=226/NAMESPACE)
 Main PID: 317 (code=exited, status=226/NAMESPACE)

May 10 01:45:45 localhost systemd[1]: Unit systemd-networkd.service entered failed state.
May 10 01:45:45 localhost systemd[1]: systemd-networkd.service failed.
May 10 01:45:45 localhost systemd[1]: systemd-networkd.service has no holdoff time, scheduling restart.
May 10 01:45:45 localhost systemd[1]: start request repeated too quickly for systemd-networkd.service
May 10 01:45:45 localhost systemd[1]: Failed to start Network Service.
May 10 01:45:45 localhost systemd[1]: Unit systemd-networkd.service entered failed state.
May 10 01:45:45 localhost systemd[1]: systemd-networkd.service failed.
May 10 01:45:45 localhost systemd[1]: start request repeated too quickly for systemd-networkd.service
May 10 01:45:45 localhost systemd[1]: Failed to start Network Service.
May 10 01:45:45 localhost systemd[1]: systemd-networkd.service failed.

systemctl  status systemd-networkd.socket -l                                                             
��● systemd-networkd.socket - networkd rtnetlink socket
   Loaded: loaded (/usr/lib/systemd/system/systemd-networkd.socket; enabled; vendor preset: disabled)
   Active: failed (Result: service-failed-permanent) since Tue 2011-05-10 01:45:45 UTC; 39min ago
     Docs: man:systemd-networkd.service(8)
           man:rtnetlink(7)
   Listen: route 273 (Netlink)

May 10 01:45:45 localhost systemd[1]: Unit systemd-networkd.socket entered failed state.
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

我应该提到 NetworkManager 和 DHClient 均未安装。由于这是最小安装,因此我想展示正在运行的进程:

ps -ax
  PID TTY      STAT   TIME COMMAND
    1 ?        Ss     0:09 /init
    2 ?        S      0:00 [kthreadd]
    3 ?        S      0:00 [ksoftirqd/0]
    5 ?        S<     0:00 [kworker/0:0H]
    7 ?        S      0:00 [migration/0]
    8 ?        S  /0]
   10 ?        S      0:00 [rcuob/1]
   11 ?        S      0:00 [rcuob/2]
   12 ?        S      0:00 [rcuob/3]
   13 ?        S      0:00 [rcu_sched]
   14 ?        S      0:00 [rcuos/0]
   15 ?        S      0:00 [rcuos/1]
   16 ?        S      0:00 [rcuos/2]
   17 ?        S      0:00 [rcuos/3]
   18 ?        S      0:00 [watchdog/0]
   19 ?        S      0:00 [watchdog/1]
   20 ?        S      0:00 [migration/1]
   21 ?        S      0:00 [ksoftirqd/1]
   23 ?        S<     0:00 [kworker/1:0H]
   24 ?        S<     0:00 [khelper]
   25 ?        S      0:00 [kdevtmpfs]
   26 ?        S<     0:00 [netns]
   27 ?        S<     0:00 [perf]
   28 ?        S<     0:00 [writeback]
   29 ?        S<     0:00 [kintegrityd]
   30 ?        S<     0:00 [bioset]
   31 ?        S<     0:00 [kblockd]
   32 ?        S<     0:00 [md]
   33 ?        S      0:00 [kworker/0:1]
   34 ?        S      0:00 [kworker/1:1]
   38 ?        S      0:00 [khungtaskd]
   39 ?        S      0:00 [kswapd0]
   40 ?        SN     0:00 [ksmd]
   41 ?        SN     0:00 [khugepaged]
   42 ?        S      0:00 [fsnotify_mark]
   43 ?        S<     0:00 [crypto]
   51 ?        S<     0:00 [kthrotld]
   54 ?        S<     0:00 [kmpath_rdacd]
   55 ?        S      0:00 [kworker/1:2]
   56 ?        S<     0:00 [kpsmoused]
   57 ?        S      0:00 [kworker/0:2]
   58 ?        S<     0:00 [ipv6_addrconf]
   77 ?        S<     0:00 [deferwq]
   89 ?        Ss     0:00 /usr/lib/systemd/systemd-journald
   96 ?        S<     0:00 [rpciod]
  109 ?        S      0:00 [kauditd]
  110 ?        Ss     0:00 /usr/sbin/lvmetad -f
  131 ?        Ss     0:00 /usr/lib/systemd/systemd-udevd
  160 ?        S<     0:00 [events_power_ef]
  164 ?        S<     0:00 [ata_sff]
  166 ?        S      0:17 [kworker/u8:3]
  167 ?        S      0:00 [scsi_eh_0]
  169 ?        S<     0:00 [scsi_tmf_0]
  172 ?        S      0:00 [scsi_eh_1]
  173 ?        S<     0:00 [scsi_tmf_1]
  174 ?        S      0:00 [kworker/u8:4]
  175 ?        S      0:00 [scsi_eh_2]
  176 ?        S<     0:00 [scsi_tmf_2]
  177 ?        S      0:00 [scsi_eh_3]
  178 ?        S<     0:00 [scsi_tmf_3]
  181 ?        S<     0:00 [kvm-irqfd-clean]
  208 ?        S<     0:00 [kworker/0:1H]
  209 ?        S<     0:00 [kworker/1:1H]
  213 ?        S      0:00 [jbd2/sda1-8]
  214 ?        S<     0:00 [ext4-rsv-conver]
  215 ?        S<     0:00 [ext4-unrsv-conv]
  235 ?        S<sl   0:00 /sbin/auditd -n
  260 ?        SNs    0:00 /usr/sbin/alsactl -s -n 19 -c -E ALSA_CONFIG_PATH=/et
  262 ?        SNsl   0:00 /usr/libexec/rtkit-daemon
  263 ?        Ss     0:00 /bin/dbus-daemon --system --address=systemd: --nofork
  268 ?        Ss     0:00 avahi-daemon: running [linux.local]
  269 ?        Ssl    0:00 /usr/bin/python -Es /usr/sbin/firewalld --nofork --no
  270 ?        Ss     0:00 /usr/lib/systemd/systemd-logind
  279 ?        Ss     0:00 /usr/sbin/gpm -m /dev/input/mice -t exps2
  280 ?        Ss     0:00 /usr/sbin/irqbalance --foreground
  281 ?        Ssl    0:00 /usr/sbin/rsyslogd -n
  282 ?        Ssl    0:00 /usr/sbin/gssproxy -D
  284 ?        S      0:00 avahi-daemon: chroot helper
  500 ?        Ss     0:00 /usr/sbin/sshd -D
  503 ?        Ssl    0:00 /usr/bin/python -Es /usr/sbin/tuned -l -P
  510 ?        Ssl    0:00 /usr/sbin/libvirtd
  512 ?        Ss     0:00 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.
  519 ?        Ss     0:00 /usr/sbin/crond -n
  546 tty1     Ss+    0:00 /sbin/agetty --noclear tty1 linux
  547 ?        Ss     0:00 login -- mini
  976 ?        Ssl    0:00 /usr/lib/polkit-1/polkitd --no-debug
 1022 ?        S      0:00 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/de
 1023 ?        S      0:00 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/de
 1025 ttyS0    Ss     0:00 -bash
 1057 ttyS0    S      0:00 su -
 1058 ttyS0    S      0:00 -bash
 1093 ?        Ss     0:00 /usr/sbin/anacron -s
15547 ttyS0    R+     0:00 ps -ax

我发现一件有趣的事情是 /init 被列为 PID 1,但 ps -p 1 -o comm= 显示我正在运行 systemd。另外:

[root@localhost tmp]# pstree

systemd-+-agetty
        |-alsactl
        |-anacron
        |-auditd---{auditd}
        |-avahi-daemon---avahi-daemon
        |-crond
        |-dbus-daemon
        |-dnsmasq---dnsmasq
        |-firewalld---{firewalld}
        |-gpm
        |-gssproxy---5*[{gssproxy}]
        |-irqbalance
        |-libvirtd---15*[{libvirtd}]
        |-login---bash---su---bash---pstree
        |-lvmetad
        |-polkitd---5*[{polkitd}]
        |-rsyslogd---2*[{rsyslogd}]
        |-rtkit-daemon---2*[{rtkit-daemon}]
        |-sshd
        |-systemd-journal
        |-systemd-logind
        |-systemd-udevd
        |-tuned---4*[{tuned}]
        `-xinetd

如果您能告诉我该怎么做才能让 systemd-networkd.service 和 systemd-networkd.socket 成功加载,我将不胜感激。

答案1

它以 退出226/NAMESPACE,这通常意味着它无法进入命名空间来启用.service文件中指定的保护。

至少有两种方法可以解决这个问题。

这是简单但不太安全的方法。

复制/usr/lib/systemd/system/systemd-networkd.service/etc/systemd/system/,用你喜欢的编辑器打开副本,然后删除以 开头的行Protect。这将禁用沙盒,并应允许其启动。

更先进但更安全

使用 重新编译内核CONFIG_NAMESPACES=y

相关内容