重新启动或“systemctl daemon-reload”以更改/etc/systemd/system.conf?

Jef*_*ina 12 systemd

在 CentOS-7 中,systemd 的 /etc/systemd/system.conf 中的选项更改需要重新启动还是“systemctl daemon-reload”就足够了?

Spo*_*ler 20

不,daemon-reload 将重新加载所有单元文件,而不是 systemd 本身的配置。但是,# systemctl daemon-reexec将重新执行 systemd 并使其在此过程中消化其新配置。

从 systemctl 手册页:

daemon-reexec
       Reexecute the systemd manager. This will serialize the manager
       state, reexecute the process and deserialize the state again. This
       command is of little use except for debugging and package upgrades.
       Sometimes, it might be helpful as a heavy-weight daemon-reload.
       While the daemon is being reexecuted, all sockets systemd listening
       on behalf of user configuration will stay accessible.
Run Code Online (Sandbox Code Playgroud)

当手册页说 daemon-reexec 对软件包升级很有用时,这在很大程度上意味着该命令执行任何新的二进制文件并重新处理其配置。但是,我们用来升级 systemd 的 RPM 已经包含一个脚本来执行此操作,因此在正常升级的情况下通常不需要它。

或者你可以重新启动。要么会做。

  • 请注意,systemd RPM 包包含一个 scriptlet,它在升级包时已经 daemon-reexec,因此在这种情况下您无需手动执行此操作。 (3认同)
  • 唯一真正需要重新启动的是内核。大多数(如果不是全部)服务在升级期间使用“systemctl try-restart”从 RPM 脚本内重新启动(如果它们已经在运行)。 (2认同)
  • @MichaelHampton 这确实有点棘手:不仅内核,而且 libc(有时,设备映射器用户空间)升级都需要完全重新启动。当然,您可以确定并重新启动每个受影响的服务,但是由于基本上*所有* 服务都与 libc 相关联,因此,重新启动通常会更快... (2认同)
  • @Motivated `libc` 不是一个服务,而是 GNU C 库,几乎所有 Linux 可执行文件都链接它。因此,在“libc”升级之后,您应该重新启动任何正在运行的程序/进程;更简单的方法是重新启动机器。 (2认同)