这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
jaysnote:systemd [2018/11/12 16:41] jaylee |
jaysnote:systemd [2019/01/29 12:47] jaylee |
||
---|---|---|---|
行 1: | 行 1: | ||
- | < | + | < |
# systemd | # systemd | ||
+ | |||
+ | * [Systemd](https:// | ||
+ | |||
+ | * [system V与systemd](https:// | ||
## man systemd | ## man systemd | ||
- | systemd 是linux操作系统的系统和服务管理器,在boot启动后的第一个进程(PID=1),systemd扮演初始化系统,其启动和维护用户空间服务。 | + | systemd 是linux操作系统的系统和服务管理器,作为boot启动后的第一个进程(PID=1),systemd扮演初始化系统,以及启动和维护用户空间服务。 |
+ | |||
+ | 为了兼容SysV,如果systemd初始化被调用并且进程id不是1,它将执行`telinit`,并且将同步参数到该应用,所以在正常系统登录状态下的init和telinit是等同的。更多信息通过`man telinit` 了解。 | ||
+ | |||
+ | 当作为系统实例启动,systemd通过`system.conf` 解析配置文件,如果作为用户进程启动,从`user.conf`解析配置文件, | ||
+ | |||
+ | ## systemd vs sysv init | ||
+ | |||
+ | * 系统同时存在sysV init脚本使能和systemd service,那么到底是生谁效的? | ||
+ | |||
+ | 如果同时存在systemd 单元文件和sysVinit脚本,亦或者upstart配置文件,理论上systemd> | ||
+ | |||
+ | * 如下路径的unit 关系,哪些unit是使能的? | ||
+ | |||
+ | 参考 `man systemctl `-> | ||
+ | |||
+ | 在`/ | ||
+ | |||
+ | ```bash | ||
+ | $ cat watchdog.service | ||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | ``` | ||
+ | |||
+ | ```bash | ||
+ | $ tree / | ||
+ | / | ||
+ | ├── multi-user.target.wants | ||
+ | │ ├── watchdog.service -> / | ||
+ | ``` | ||
+ | |||
+ | 可以通过`systemctl list-unit-files |grep enable `查找所有使能的unit文件,同时可以通过`systemctl preset-all `复位所有使能的unit file。 | ||
+ | |||
+ | * systemd如何控制sysV init脚本? | ||
+ | |||
+ | ```bash | ||
+ | / | ||
+ | / | ||
+ | ``` | ||
+ | |||
+ | 如果同时存在`supervisor.service` 和对应软连接,此时启动由systemd控制,并且状态为`enable`。 | ||
+ | |||
+ | ```bash | ||
+ | $ systemctl list-unit-files |grep supervisor | ||
+ | supervisor.service | ||
+ | ``` | ||
+ | |||
+ | 如果存在`superviosr.service`不存在对应的软连接,此时启动有systemd控制,状态为`disable`, | ||
+ | |||
+ | ```bash | ||
+ | $ systemctl list-unit-files |grep supervisor | ||
+ | supervisor.service | ||
+ | ``` | ||
+ | |||
+ | ``` | ||
+ | / | ||
+ | / | ||
+ | ``` | ||
+ | |||
+ | 如果同时存在`supervisor`和`S01supervisor` | ||
+ | |||
+ | 如上问题还是只有从`man systemctl` 当中找答案哦。 | ||
+ | |||
+ | |||
+ | ## systemd command | ||
+ | |||
+ | ```bash | ||
+ | systemctl (1) - Control the systemd system and service manager | ||
+ | systemd (1) - systemd system and service manager | ||
+ | systemd-activate (8) - Test socket activation of daemons | ||
+ | systemd-analyze (1) - Analyze system boot-up performance | ||
+ | systemd-ask-password (1) - Query the user for a system password | ||
+ | systemd-ask-password-console.path (8) - Query the user for system passwords on the console and via wall | ||
+ | systemd-ask-password-console.service (8) - Query the user for system passwords on the console and via wall | ||
+ | systemd-ask-password-wall.path (8) - Query the user for system passwords on the console and via wall | ||
+ | systemd-ask-password-wall.service (8) - Query the user for system passwords on the console and via wall | ||
+ | systemd-backlight (8) - Load and save the display backlight brightness at boot and shutdown | ||
+ | systemd-backlight@.service (8) - Load and save the display backlight brightness at boot and shutdown | ||
+ | systemd-binfmt (8) - Configure additional binary formats for executables at boot | ||
+ | systemd-binfmt.service (8) - Configure additional binary formats for executables at boot | ||
+ | systemd-bootchart (1) - Boot performance graphing tool | ||
+ | systemd-cat (1) - Connect a pipeline or program' | ||
+ | systemd-cgls (1) - Recursively show control group contents | ||
+ | systemd-cgtop (1) - Show top control groups by their resource usage | ||
+ | systemd-cryptsetup (8) - Full disk decryption logic | ||
+ | systemd-cryptsetup-generator (8) - Unit generator for / | ||
+ | systemd-cryptsetup@.service (8) - Full disk decryption logic | ||
+ | systemd-debug-generator (8) - Generator for enabling a runtime debug shell and masking specific units at boot | ||
+ | systemd-delta (1) - Find overridden configuration files | ||
+ | systemd-detect-virt (1) - Detect execution in a virtualized environment | ||
+ | systemd-efi-boot-generator (8) - Generator for automatically mounting the EFI System Partition used by the current boot to /boot | ||
+ | systemd-escape (1) - Escape strings for usage in system unit names | ||
+ | systemd-fsck (8) - File system checker logic | ||
+ | systemd-fsck-root.service (8) - File system checker logic | ||
+ | systemd-fsck@.service (8) - File system checker logic | ||
+ | systemd-fstab-generator (8) - Unit generator for / | ||
+ | systemd-getty-generator (8) - Generator for enabling getty instances on the console | ||
+ | systemd-gpt-auto-generator (8) - Generator for automatically discovering and mounting root, /home and /srv partitions, as well as discovering and enabling swap partitions, based on GPT par... | ||
+ | systemd-halt.service (8) - System shutdown logic | ||
+ | systemd-hibernate.service (8) - System sleep state logic | ||
+ | systemd-hostnamed (8) - Host name bus mechanism | ||
+ | systemd-hostnamed.service (8) - Host name bus mechanism | ||
+ | systemd-hybrid-sleep.service (8) - System sleep state logic | ||
+ | systemd-inhibit (1) - Execute a program with an inhibition lock taken | ||
+ | systemd-initctl (8) - / | ||
+ | systemd-initctl.service (8) - / | ||
+ | systemd-initctl.socket (8) - / | ||
+ | systemd-journald (8) - Journal service | ||
+ | systemd-journald-dev-log.socket (8) - Journal service | ||
+ | systemd-journald.service (8) - Journal service | ||
+ | systemd-journald.socket (8) - Journal service | ||
+ | systemd-kexec.service (8) - System shutdown logic | ||
+ | systemd-localed (8) - Locale bus mechanism | ||
+ | systemd-localed.service (8) - Locale bus mechanism | ||
+ | systemd-logind (8) - Login manager | ||
+ | systemd-logind.service (8) - Login manager | ||
+ | systemd-machine-id-setup (1) - Initialize the machine ID in / | ||
+ | systemd-machined (8) - Virtual machine and container registration manager | ||
+ | systemd-machined.service (8) - Virtual machine and container registration manager | ||
+ | systemd-modules-load (8) - Configure kernel modules to load at boot | ||
+ | systemd-modules-load.service (8) - Configure kernel modules to load at boot | ||
+ | systemd-networkd (8) - Network manager | ||
+ | systemd-networkd-wait-online (8) - Wait for network to come online | ||
+ | systemd-networkd-wait-online.service (8) - Wait for network to come online | ||
+ | systemd-networkd.service (8) - Network manager | ||
+ | systemd-notify (1) - Notify service manager about start-up completion and other daemon status changes | ||
+ | systemd-nspawn (1) - Spawn a namespace container for debugging, testing and building | ||
+ | systemd-path (1) - List and query system and user paths | ||
+ | systemd-poweroff.service (8) - System shutdown logic | ||
+ | systemd-quotacheck (8) - File system quota checker logic | ||
+ | systemd-quotacheck.service (8) - File system quota checker logic | ||
+ | systemd-random-seed (8) - Load and save the system random seed at boot and shutdown | ||
+ | systemd-random-seed.service (8) - Load and save the system random seed at boot and shutdown | ||
+ | systemd-readahead (8) - Disk read ahead logic | ||
+ | systemd-readahead-collect.service (8) - Disk read ahead logic | ||
+ | systemd-readahead-done.service (8) - Disk read ahead logic | ||
+ | systemd-readahead-done.timer (8) - Disk read ahead logic | ||
+ | systemd-readahead-replay.service (8) - Disk read ahead logic | ||
+ | systemd-reboot.service (8) - System shutdown logic | ||
+ | systemd-remount-fs (8) - Remount root and kernel file systems | ||
+ | systemd-remount-fs.service (8) - Remount root and kernel file systems | ||
+ | systemd-resolved (8) - Network Name Resolution manager | ||
+ | systemd-resolved.service (8) - Network Name Resolution manager | ||
+ | systemd-rfkill (8) - Load and save the RF kill switch state at boot and shutdown | ||
+ | systemd-rfkill@.service (8) - Load and save the RF kill switch state at boot and shutdown | ||
+ | systemd-run (1) - Run programs in transient scope or service units | ||
+ | systemd-shutdown (8) - System shutdown logic | ||
+ | systemd-shutdownd (8) - Scheduled shutdown service | ||
+ | systemd-shutdownd.service (8) - Scheduled shutdown service | ||
+ | systemd-shutdownd.socket (8) - Scheduled shutdown service | ||
+ | systemd-sleep (8) - System sleep state logic | ||
+ | systemd-sleep.conf (5) - Suspend and hibernation configuration file | ||
+ | systemd-socket-proxyd (8) - Bidirectionally proxy local sockets to another (possibly remote) socket. | ||
+ | systemd-suspend.service (8) - System sleep state logic | ||
+ | systemd-sysctl (8) - Configure kernel parameters at boot | ||
+ | systemd-sysctl.service (8) - Configure kernel parameters at boot | ||
+ | systemd-system-update-generator (8) - Generator for redirecting boot to offline update mode | ||
+ | systemd-system.conf (5) - System and session service manager configuration file | ||
+ | systemd-sysusers (8) - Allocate system users and groups | ||
+ | systemd-sysusers.service (8) - Allocate system users and groups | ||
+ | systemd-timedated (8) - Time and date bus mechanism | ||
+ | systemd-timedated.service (8) - Time and date bus mechanism | ||
+ | systemd-timesyncd (8) - Network Time Synchronization | ||
+ | systemd-timesyncd.service (8) - Network Time Synchronization | ||
+ | systemd-tmpfiles (8) - Creates, deletes and cleans up volatile and temporary files and directories | ||
+ | systemd-tmpfiles-clean.service (8) - Creates, deletes and cleans up volatile and temporary files and directories | ||
+ | systemd-tmpfiles-clean.timer (8) - Creates, deletes and cleans up volatile and temporary files and directories | ||
+ | systemd-tmpfiles-setup-dev.service (8) - Creates, deletes and cleans up volatile and temporary files and directories | ||
+ | systemd-tmpfiles-setup.service (8) - Creates, deletes and cleans up volatile and temporary files and directories | ||
+ | systemd-tty-ask-password-agent (1) - List or process pending systemd password requests | ||
+ | systemd-udevd (8) - Device event managing daemon | ||
+ | systemd-udevd-control.socket (8) - Device event managing daemon | ||
+ | systemd-udevd-kernel.socket (8) - Device event managing daemon | ||
+ | systemd-udevd.service (8) - Device event managing daemon | ||
+ | systemd-update-utmp (8) - Write audit and utmp updates at bootup, runlevel changes and shutdown | ||
+ | systemd-update-utmp-runlevel.service (8) - Write audit and utmp updates at bootup, runlevel changes and shutdown | ||
+ | systemd-update-utmp.service (8) - Write audit and utmp updates at bootup, runlevel changes and shutdown | ||
+ | systemd-user-sessions (8) - Permit user logins after boot, prohibit user logins at shutdown | ||
+ | systemd-user-sessions.service (8) - Permit user logins after boot, prohibit user logins at shutdown | ||
+ | systemd-user.conf (5) - System and session service manager configuration file | ||
+ | systemd.automount (5) - Automount unit configuration | ||
+ | systemd.device (5) - Device unit configuration | ||
+ | systemd.directives (7) - Index of configuration directives | ||
+ | systemd.exec (5) - Execution environment configuration | ||
+ | systemd.index (7) - List all manpages from the systemd project | ||
+ | systemd.journal-fields (7) - Special journal fields | ||
+ | systemd.kill (5) - Process killing procedure configuration | ||
+ | systemd.link (5) - Network device configuration | ||
+ | systemd.mount (5) - Mount unit configuration | ||
+ | systemd.netdev (5) - Virtual Network Device configuration | ||
+ | systemd.network (5) - Network configuration | ||
+ | systemd.path (5) - Path unit configuration | ||
+ | systemd.preset (5) - Service enablement presets | ||
+ | systemd.resource-control (5) - Resource control unit settings | ||
+ | systemd.scope (5) - Scope unit configuration | ||
+ | systemd.service (5) - Service unit configuration | ||
+ | systemd.slice (5) - Slice unit configuration | ||
+ | systemd.snapshot (5) - Snapshot unit configuration | ||
+ | systemd.socket (5) - Socket unit configuration | ||
+ | systemd.special (7) - Special systemd units | ||
+ | systemd.swap (5) - Swap unit configuration | ||
+ | systemd.target (5) - Target unit configuration | ||
+ | systemd.time (7) - Time and date specifications | ||
+ | systemd.timer (5) - Timer unit configuration | ||
+ | systemd.unit (5) - Unit configuration | ||
+ | ``` | ||
+ | |||
+ | ## systemd source review | ||
+ | |||
+ | * https:// | ||
+ | * https:// | ||
- | 为了兼容SysV,如果systemd以初始化被调用并且进程id不是1,它将执行`telinit` | ||
- | 当做为系统实例启动,systemd从`system.conf` 配置文件开始解释,否则从`user.conf`, | ||
</ | </ | ||