From Fedora Project Wiki

systemd 是Linux下一个与SysV和LSB init scripts兼容的系统和服务管理器。systemd 使用socket和D-Bus来开启服务,提供基于守护进程的按需启动策略,保留了Linux cgroups的进程追踪功能,支持快照和系统状态恢复,维护挂载和自挂载点,实现了各服务间基于从属关系的一个更为精细的逻辑控制,拥有前卫的并行性能。它也可以降级作为sysvinit的一个替代品。更多信息,请参考视频:http://linuxconfau.blip.tv/file/4696791/http://www.youtube.com/watch?v=TyMLi8QF6sw

Note.png
对于系统管理员
系统管理员如果想了解如何使用本地命令systemctl 来替换SysVinit 的工作流程,可以访问此页。需要注意的是,在systemd 的世界里servicechkconfig 命令将继续像之前一样工作。


为什么是systemd?

http://0pointer.de/blog/projects/why.html

介绍

systemd 开启和监督整个系统是基于unit 的概念。unit 由一个与配置文件对应的名字和类型组成的(例如: avahi.service unit 有一个具有相同名字的配置文件,是守护进程Avahi 的一个封装单元)。unit 有以下几种类型:

  1. service :守护进程的启动、停在、重启和重载是此类unit 最为明显的类型。
  2. socket :此类unit 封装系统和互联网中的一个套接口。当下,systemd 支持流式、数据报和连续包的AF_INET、AF_INET6、AF_UNIX 接口。也支持传统的FIFOs 传输模式。每一个套接口unit 都有一个相应的服务unit 。相应的服务在第一个连接进入socket 或FIFO 时就会启动(例如:nscd.socket 在有新连接后便启动nscd.service )。
  3. device :此类unit 封装一个存在于Linux 设备树中的设备。每一个使用udev 规则标记的设备都将会在systemd 中作为一个设备unit 出现。udev 的属性设置可以作为配置设备unit 依赖关系的配置源。
  4. mount :此类unit 封装系统结构层次中的一个挂载点。
  5. automount :此类unit 封装系统结构层次中的一个自挂载点。每一个自挂载unit 对应一个已挂载的挂载unit (需要在自挂载目录可以存取的情况下尽早挂载)。
  6. target :此类unit 为其他unit 进行逻辑分组。它们本身实际上并不做什么,只是引用其他unit 而已。这样便可以对unit 做一个统一的控制。(例如:multi-user.target 相当于在传统使用SysV 的系统中运行级别5;bluetooth.target 只有在蓝牙适配器可用的情况下才调用与蓝牙相关的服务,如:bluetooth 守护进程、obex 守护进程等)
  7. snapshot :与target unit 相似,快照本身不做什么,唯一的目的就是引用其他unit

文档

特性

工具

内核启动命令行

Fedora 中systemd 的开发状态

System V init 与systemd 的对接

systemd 的服务管理程序

如何启动/关闭、开启/禁用服务?

如何改变运行级别?

如何改变默认运行级别?

如何查看当下运行级别?

如何关机?

service 命令兼容systemd 吗?

chkconfig 命令兼容systemd 吗?

system-config-services 与systemd 兼容吗?

如何改变默认gettys 号?

虚拟终端如何设置自动登录?

如何自定义或增加一个自定义unit 文件?

unit文件在/etc/systemd/system下的优先级要高于/lib/systemd/system下的。按照个人的需求从后者移动到前者并进行自定义修改。

If a line starts with .include followed by a file name, the specified file will be parsed at this point. Make sure that the file that is included has the appropiate section headers before any directives.

You should use .include statement instead of copying the whole unit file from /lib/systemd/system to /etc/systemd/system if possible. This will enable to update the unchanged directives correctly during future package updates.

Be careful when using .include together with directives that can be defined multiple times (like EnvironmentFile=), since we can only add new directives, but we can't remove already defined ones. We have to copy the whole file from /lib/systemd/system to /etc/systemd/system in this case.

Let's say we use a lighttpd server and we want to lower its niceness value. All we need to do is to add Nice=-5 to the lighttpd.service file. We can do this by either copying the whole file from /lib/systemd/system/lighttpd.service to /etc/systemd/system/lighttpd.service or creating the following file in /etc/systemd/system/lighttpd.service:

如何调试系统事件?

预读功能

关于/usr 分区的警告

详情请参考: http://freedesktop.org/wiki/Software/systemd/separate-usr-is-brokenhttp://cgit.freedesktop.org/systemd/tree/README

man 手册

systemd 有多方面的文档,其中也包括一些man手册页。其网页版地址是: http://0pointer.de/public/systemd-man/

参考