systemd
#
Systemd#
Tips- systemd
- wikipedia systemd
- systemd.unit
- systemctl manpage
- How To Use Systemctl to Manage Systemd Services and Units
- 配置目录
/etc/systemd/system/docker.service.d/*.conf
/etc/systemd/system/
/lib/systemd/system/
- 参考
command | mean |
---|---|
查询 | - |
systemctl list-dependencies | unit 依赖 |
systemctl list-sockets | sockets 状态 |
systemctl list-jobs | 活跃 jobs |
systemctl list-unit-files | unit 文件和状态 |
systemctl list-units | units loaded/active |
systemctl get-default | default target (like run level) |
服务 | - |
systemctl stop service | 停止 |
systemctl start service | 启动 |
systemctl restart service | 重启 |
systemctl reload service | 配置重载 |
systemctl daemon-reload | 重载 unit 文件 |
systemctl status service | 服务状态 |
systemctl --failed | 失败的服务 |
systemctl reset-failed | 重置失败的状态 |
systemctl enable service | 服务自启动 |
systemctl disable service | 关闭自启动 |
systemctl show service | 服务信息 |
systemctl edit service | 编辑 unit |
systemctl edit --full service | 编辑服务 |
systemctl -H host status network | 远程执行 |
系统状态 | - |
systemctl reboot | 重启 / reboot.target |
systemctl poweroff | 关机 / poweroff.target |
systemctl emergency | emergency.target |
systemctl default | 恢复到默认 multi-user.target |
日志 | - |
journalctl | 所有日志 |
journalctl -u network.service | 网络服务日志 |
journalctl -f | 跟随显示 |
journalctl -k | 内核日志 |
util | desc |
---|---|
systemctl | 主要命令 |
journalctl | |
notify | |
systemd-analyze | 查看启动耗时 |
cgls | |
cgtop | |
loginctl | 当前登陆用户 |
nspwan | |
hostnamectl | 查看和管理主机信息 |
localectl | 本地化配置 |
timedatectl | 时区 |
daemon | desc |
---|---|
systemd | |
journald | |
networkd | |
logind | |
user session |
unit | desc |
---|---|
Service | 系统服务 |
Target | 多个 Unit 构成的一个组 |
Device | 硬件设备 |
Mount | 文件系统的挂载点 |
Automount | 自动挂载点 |
Path | 文件或路径 |
Scope | 不是由 Systemd 启动的外部进程 |
Slice | 进程组 |
Snapshot | Systemd 快照,可以切回某个快照 |
Socket | 进程间通信的 socket |
Swap | swap 文件 |
Timer | 定时器 |
#
Unit 文件#
TargetUnit 组, 类似于其他 init 的 runlevel 概念
runlevel | target name | link |
---|---|---|
Runlevel 0 | runlevel0.target | poweroff.target |
Runlevel 1 | runlevel1.target | rescue.target |
Runlevel 2 | runlevel2.target | multi-user.target |
Runlevel 3 | runlevel3.target | multi-user.target |
Runlevel 4 | runlevel4.target | multi-user.target |
Runlevel 5 | runlevel5.target | graphical.target |
Runlevel 6 | runlevel6.target | reboot.target |
#
Target vs init/RunLevel- init/RunLevel
- 默认 RunLevel /etc/inittab
- 脚本位于 /etc/init.d - 等同于 Unit
- 启动的脚本 link 到 /etc/rc.d 或 /etc/runlevels/
- init 配置位于
/etc/sysconfig
或/etc/rc.conf
- Target
- 默认 /etc/systemd/system/default.target
- link 到 multi-user.target 或 graphical.target
- Unit 位于 /lib/systemd/system
- 启动后位于 /etc/systemd/system
- systemd 配置 /lib/systemd, /etc/systemd
- 默认 /etc/systemd/system/default.target
#
Example/etc/systemd/system/prometheus-node-exporter.service
#
FAQ#
Why archlinux migrate to systemd- Archlinux is moving to systemd - 2012-08