Translation(s): English - Español - Français - 한국어 - Brasileiro - Russian - 简体中文
systemd - менеджер системы и сервисов
Contents
Введение
systemd представляет собой менеджер системы и сервисов для Linux, совместимый с SysV и LSB сценариями. systemd обеспечивает возможности агрессивного распараллеливания, использует сокет и D-Bus для начала активации сервиса по требованию, запуск демонов в фоновом режиме, отслеживает процессы, использующие Linux cgroups, поддерживает мгновенные снимки и восстановление состояния системы, поддерживает подключения и автоматическое монтирование точек и реализует разработку логики транзакционных зависимостей службы управления. Он может работать как замена для Sysvinit.
Установка
Начиная с версии (20-1) systemd полностью вошло в хранилище testing. Начиная с версии (25-1) systemd имеет поддержку /run.
Чтобы установить systemd запустите:
# apt-get update # apt-get install systemd
Вам также необходимо ядро со следующими включенными параметрами:
- CONFIG_DEVTMPFS=y
- CONFIG_CGROUPS=y
- CONFIG_AUTOFS4_FS=[y|m]
- CONFIG_IPV6=[y|m], опционально, но очень рекомендуется
CONFIG_FANOTIFY=y, опционально, требуется для systemd readahead. Доступен в ядре Linux >= 2.6.37-rcX. Должен быть активирован для ядра Debian Linux (605636).
Начиная с v8 cgroupfs монтируется в /sys/fs/cgroup. Для этого требуется ядро Linux >= 2.6.36 или бэкпортирование этого патча.
Требуется ядро Linux (>= 2.6.39) на данный момент.
Пакеты Debian с родной поддержкой systemd
(>=1.4.0-1) |
testing |
supports socket activation |
|
(>=5.7.1-1) |
testing |
supports socket activation, run systemctl enable rsyslog.service |
|
(>=0.5.14-4) |
testing |
supports D-Bus activation |
|
(>=0.4.3-1) |
testing |
supports D-Bus activation |
|
(>=0.6.28-1) |
testing |
avahi-daemon: supports socket and D-Bus activation, avahi-dnsconfd: started by multi-user.target. Run systemctl enable avahi-daemon.service resp. systemctl enable avahi-dnsconfd.service. |
|
(>=0.8.2-3) |
testing |
supports D-Bus activation, run systemctl enable NetworkManager.service |
|
(>=165-1) |
testing |
enabled by default, started via basic.target |
|
(>=0.9-3) |
testing |
supports D-Bus activation |
|
(>=2.58-1) |
testing |
|
|
(>=0.7.3-1) |
testing |
|
|
(>=3.0.9-1) |
testing |
|
|
(>=1.8.3p1-3) |
testing |
|
|
(>=1.4.30-1) |
testing |
|
Пример (для rsyslog: Ручная активация сервиса после инсталляции):
# systemctl enable rsyslog.service Вывод: ln -s '/lib/systemd/system/rsyslog.service' '/etc/systemd/system/multi-user.target.wants/rsyslog.service'
Известные проблемы и способы их решения
Issue #1: sysvinit vs. systemd-sysv
sysvinit является текущей по умолчанию системой инициализации в Debian и помечен как "Essential" пакет. Это означает, что инструменты управления пакетами откажутся удалить или заменить пакет если только не принудительно. Кроме того, при выполнении dist-upgrades основные пакеты станут предпочтительнее и будут вновь установлены. Для получения большей информации см.chapters "3.8 Essential packages" and "5.6.9 Essential"
Пакет systemd-sysv package имеет в составе /sbin/init (как символьную ссылку на /bin/systemd) и следовательно, конфликтует с пакетом sysvinit .
Решение #1: Не устанавливать systemd-sysv, изменить строку grub (Kernel command line) добавлением параметра "init=/bin/systemd". Для grub2 постоянным решением является это (требует выполнения update-grub для обновления /boot/grub/grub.cfg):
# $EDITOR /etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT="quiet init=/bin/systemd" <--- Измените эту строку # update-grub
Workaround #2: Установить пакет systemd-sysv и закрепить его ("hold").
Имеется проблема с "Essential flag" что необходимо обсудить с сопровождающим ?DebianPkg: Sysvinit .
Issue #2: Warning: "/etc/mtab is not a symlink or not pointing to /proc/self/mounts"
This issue is only a warning and can be ignored, we have it on TODO (see below "Make /etc/mtab a symlink to /proc/self/mounts. Requires a newer util-linux package which stores user options separately."). (494001)
The full error-message in dmesg:
[ 5.784886] systemd[1]: /etc/mtab is not a symlink or not pointing to /proc/self/mounts. This is not supported anymore. Please make sure to replace this file by a symlink to avoid incorrect or misleading mount(8) output.
Workaround: Create required symlink:
# ln -sf /proc/self/mounts /etc/mtab
Issue #3: Dependency cycle in portmap/nfs-common/rpcbind
The nfs-common / portmap / rpcbind SysV init scripts have a dependency cycle which will cause systemd to drop them. You will get an error message during boot like the following:
Found ordering cycle path on basic.target/start Walked on cycle path to sysinit.target/start Walked on cycle path to portmap.service/start Walked on cycle path to basic.target/start Breaking ordering cycle by deleting job portmap.service
Until the portmap / nfs-common / rpcbind init scripts have been fixed, you can get rid of those error messages by uninstalling those packages or fixing their LSB init header manually.
This problem is caused by portmap / nfs-common / rpcbind installing symlinks in both rcS and rc{2345}, see 623377
Issue #3a: Dependency cycle breakage caused by nfs-common
A similar problem as above, but with a worse automatic resolution:
Found ordering cycle on basic.target/start Walked on cycle path to sockets.target/start Walked on cycle path to dbus.socket/start Walked on cycle path to sysinit.target/start Walked on cycle path to nfs-common.service/start Walked on cycle path to basic.target/start Breaking ordering cycle by deleting job dbus.socket/start
Corresponding bug report: 622394
Родное монтирование
With v12 or later you can use native (means systemd's) mount and fsck facility by making sure it is activated in /etc/systemd/system.conf.
# egrep 'MountAuto|SwapAuto' /etc/systemd/system.conf Output: MountAuto=yes SwapAuto=yes
The Debian package enables native mount by default since version 15-1.
If you use Logical-Volume-Manager (LVM) make sure to upgrade your lvm2 package to the latest version available from unstable (>= 2.02.84-1) as it contains important fixes regarding the udev integration. See 603710 for more details. The 19-1 package already does this.
Отладка systemd
Sometimes it is necessary to investigate why systemd hangs on startup or on reboot/shutdown.
Solution #0: Remove "quiet" from Kernel command line (so called "cmdline" or "grub line")
Solution #1: Increase verbosity via cmdline: Add "systemd.log_target=kmsg systemd.log_level=debug"
Of course you can have a "temporary" persistent solution:
[ /etc/default/grub ] GRUB_CMDLINE_LINUX="systemd.log_target=kmsg systemd.log_level=debug" <--- Add here (by uncommenting you can easily switch to debug) # update-grub
In addition enhance cmdline with "systemd.sysv_console=1" (0: disabled, 1: enabled).
Solution #2: Increase verbosity via /etc/systemd/system.conf
LogLevel=debug <--- Uncomment this line and use "debug" (default: commented and "info") LogTarget=syslog-or-kmsg <--- Uncomment this line (default: commented) SysVConsole=yes <--- Uncomment this line (default: commented)
HINT: "man system" and "man systemd.conf" (Note: File is system.conf vs. man-page system*d*.conf)
HINT: How to check Kernel command line parameters/options?
# cat /proc/cmdline
NOTE on ?LogLevel (see systemd(1) and systemd.conf(5)):
"Set log level. As argument this accepts a numerical log level or the well-known syslog(3) symbolic names (lowercase): emerg, alert, crit, err, warning, notice, info, debug."
HINT: Keep a copy of /sbin/init from sysvinit package in case of rescue (so you can use init=/sbin/init.sysvinit in cmdline)!
# cp -av /sbin/init /sbin/init.sysvinit <--- Before installing systemd-sysv package
See also https://fedoraproject.org/wiki/How_to_debug_Systemd_problems
Ошибки и системы сбора ошибок
- For known bugs please see topic "Known Issues and Workarounds"
TODO
- Update more packages to ship systemd service files.
- Draft a packaging policy involving systemd (upgrade / install / removal).
- Provide integration for package maintainer tools: "dh_systemd"
- invoke-rc.d/update-rc.d/service integration.
- Get Essential flag removed from sysvinit.
- Sort out what to do about pam_loginuid, and integration into the Debian PAM stack
- Decide what to do about group:lock (/var/lock).
- Make /etc/mtab a symlink to /proc/self/mounts. Requires a newer util-linux package which stores user options separately.
- Make systemd-vconsole work. Investigate which of the console-* and kbd* packages are actually required and how to migrate the configuration.
- Migration of /etc/inittab settings.
Random thoughts: Check the whiteboard
Deprecate /lib/init/rw: /run migration
Get other syslog implementations updated to support socket activation: https://bugzilla.novell.com/show_bug.cgi?id=656104
WorkInProgress
- Test cryptsetup support.
DONE
- Get libcryptsetup moved to /lib.
- Enable cryptsetup support.
Install a (auto)mount unit to mount /lib/init/rw early during boot. lib-init-rw.automount lib-init-rw.mount unit file.
Where to get help?
As systemd is a very young project (see [1]), we would appreciate to use the existing upstream infrastructure like mailing-list [2], IRC and read Lennart's blog [3], etc. for following the development. Most people interested in systemd development (from diverse distributions) and Debian-specific packaging are around on IRC: #systemd (irc.libera.chat). Anyway, Debian-specific bugs should be sent to Debian-BTS (for example use report-bug tool).
Who is who?
Maintainer of the systemd package is Tollef Fog Heen (Mithrandir). Currently, it's discussed to get Michael Biebl (mbiebl) as co-maintainer. Michael and Sedat Dilek (dileks) contributed to the initial version of this wiki.
Resources
Talk about systemd in Debian at Linux Plumbers Conference 2010 by Michael Biebl <biebl@debian.org>
References