Centos7

無法讓 systemd-networkd 成功啟動

  • January 1, 2019

我有一台帶有六個網路介面的迷你電腦,執行 CentOS 7.2 和核心 3.10,安裝最少。

我想將我的介面命名為 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 成功載入的想法將不勝感激。

它以 退出226/NAMESPACE,這通常意味著它無法進入命名空間以啟用.service文件中指定的保護。

至少有兩種方法可以解決它。

簡單且不太安全的方式。

複製/usr/lib/systemd/system/systemd-networkd.service/etc/systemd/system/,使用您喜歡的編輯器打開副本並刪除以 . 開頭的行Protect。這將禁用沙盒,並應讓它啟動。

更先進但更安全

重新編譯核心CONFIG_NAMESPACES=y

引用自:https://serverfault.com/questions/745854