![每次启动时必须手动重启 Systemd-networkd](https://linux22.com/image/1178918/%E6%AF%8F%E6%AC%A1%E5%90%AF%E5%8A%A8%E6%97%B6%E5%BF%85%E9%A1%BB%E6%89%8B%E5%8A%A8%E9%87%8D%E5%90%AF%20Systemd-networkd.png)
systemd-networkd
每次重新启动服务器时我都需要重新启动。
每次启动都无法启动,启动后服务的状态如下。如果我在启动后重新启动服务,它就可以正常工作。
● systemd-networkd.service - Network Service
Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2020-12-22 17:31:27 CET; 1min 2s ago
Docs: man:systemd-networkd.service(8)
Process: 1062 ExecStart=/lib/systemd/systemd-networkd (code=exited, status=1/FAILURE)
Main PID: 1062 (code=exited, status=1/FAILURE)
Status: "Shutting down..."
Dec 22 17:31:27 netcube_ubuntu systemd[1]: systemd-networkd.service: Service has no hold-off time, scheduling restart.
Dec 22 17:31:27 netcube_ubuntu systemd[1]: systemd-networkd.service: Scheduled restart job, restart counter is at 5.
Dec 22 17:31:27 netcube_ubuntu systemd[1]: Stopped Network Service.
Dec 22 17:31:27 netcube_ubuntu systemd[1]: systemd-networkd.service: Start request repeated too quickly.
Dec 22 17:31:27 netcube_ubuntu systemd[1]: systemd-networkd.service: Failed with result 'exit-code'.
Dec 22 17:31:27 netcube_ubuntu systemd[1]: Failed to start Network Service.
我尝试用谷歌搜索各种答案,但找不到任何相关内容... 这件事突然发生了。服务器一直运行良好,但在今天的计划重启后发生了这种情况。
这里有谁能帮助我解决可能出现的问题/如何排除故障?
答案1
选项1
检查系统中其他可能的互联网连接。来源:https://unix.stackexchange.com/questions/507225/have-to-restart-network-service-after-reboot-centos-7
选项 2
尝试设置等待服务启动。也就是说,在 中/lib/systemd/system/systemd-networkd.service
添加或附加到
After=systemd-networkd-wait-online.service
Wants=systemd-networkd-wait-online.service
然后重新启动。
部分来源:https://stackoverflow.com/a/54300998/2707864
选项 3
更改重启间隔。查找/etc/systemd/system.conf
并更改
#DefaultStartLimitIntervalSec=10s
#DefaultStartLimitBurst=5
设置为更高的值。在其他文件中可以进行更加自定义的更改,例如/lib/systemd/system/systemd-networkd.service
使用参数
RestartSec=...
StartLimitIntervalSec=...
StartLimitBurst=...
部分来源:https://serverfault.com/a/845473/326962,man systemd.service
有关的:
- https://forum.level1techs.com/t/ubuntu-need-to-manually-restart-resolved/144081/6
- 每次重启后都需要重新启动 systemd-resolved
- https://stackoverflow.com/questions/35805354/systemd-start-service-at-boot-time-after-network-is-really-up-for-wol-purpose
- https://serverfault.com/questions/845471/service-start-request-repeated-too-quickly-refusing-to-start-limit
答案2
如上所述,我将创建对 systemd-networkd-wait-online 的依赖项,但不是在系统文件 /lib/..... 中,而是创建一个文件(和一个目录)
/etc/systemd/system/systemd-networkd.service.d/override.conf
并将内容放在那里
[Unit]
After=systemd-networkd-wait-online.service
Wants=systemd-networkd-wait-online.service