+ All Categories
Home > Software > Systemd mlug-20140614

Systemd mlug-20140614

Date post: 10-Jun-2015
Category:
Upload: susant-sahani
View: 361 times
Download: 0 times
Share this document with a friend
Description:
systemd
Popular Tags:
42
Glenn Holmer Glenn Holmer Milwaukee Linux Users Group Milwaukee Linux Users Group June 14, 2014 June 14, 2014 systemd: the new init system for Linux systemd: the new init system for Linux
Transcript
Page 1: Systemd mlug-20140614

Glenn HolmerGlenn Holmer

Milwaukee Linux Users GroupMilwaukee Linux Users GroupJune 14, 2014June 14, 2014

systemd: the new init system for Linuxsystemd: the new init system for Linux

Page 2: Systemd mlug-20140614

History

Page 3: Systemd mlug-20140614

init, the father of processes

✔ BIOS loads bootloader from hard drive✔ bootloader loads GRUB✔ GRUB loads kernel✔ kernel mounts filesystems and loads drivers✔ kernel starts first process (init)

Page 4: Systemd mlug-20140614

sysvinit startup

✔ init looks for default runlevel and runs its scripts to start the appropriate services

✔ each runlevel has a directory /etc/rcN.d/ with start and stop symlinks to scripts in /etc/init.d

Page 5: Systemd mlug-20140614

init systems

traditional: sysvinit (Linux)alternate: OpenRC (Gentoo), upstart (Ubuntu)other OS: BSD, SMF (Solaris), launchd (Mac)

Page 6: Systemd mlug-20140614
Page 7: Systemd mlug-20140614

What's wrong with sysvinit?

synchronouseverything started at boot timecan't control double-forked child processes

Page 8: Systemd mlug-20140614

What's better about systemd?

asynchronousservices started only when needed (via socket)services run in cgroups

Page 9: Systemd mlug-20140614

Why is systemd controversial?

“do one thing and do it well” (feature creep)depends on dbus/kdbusLinux-specific (because of cgroups)binary log file (the journal)

http://0pointer.de/blog/projects/the-biggest-myths.html

Page 10: Systemd mlug-20140614

Why is systemd controversial?

“do one thing and do it well” (feature creep)depends on dbus/kdbusLinux-specific (because of cgroups)binary log file (the journal)

http://0pointer.de/blog/projects/the-biggest-myths.html

personality conflicts...

Page 11: Systemd mlug-20140614
Page 12: Systemd mlug-20140614

systemd adoption

Ubuntu: upstart 2006 (native init 2009)Fedora: upstart 2008, systemd 2011RHEL: RHEL 7 (just released) uses systemdSUSE: upstart option 2010, systemd 2011SLES: SLES 12 (Q3) will use systemdDebian: systemd 2014, Ubuntu will follow

Page 13: Systemd mlug-20140614

Mechanics

Page 14: Systemd mlug-20140614

Why is sysvinit synchronous?

services wait for their dependencies(which open a socket when ready)

Page 15: Systemd mlug-20140614

Why not open the socket on startup?

services with dependencies can start at oncesocket buffer holds messages until ready

Page 16: Systemd mlug-20140614

Why is sysvinit slow?

shell scripts! (shell loaded over and over)multiple invocations of grep, awk, sed...

Page 17: Systemd mlug-20140614

Why not use configuration files?

in /usr/lib/systemd/systemlocals, overrides in /etc/systemd/system

Page 18: Systemd mlug-20140614

[Unit]Description=PostgreSQL database serverAfter=network.target

[Service]Type=forkingUser=postgresGroup=postgresEnvironment=PGPORT=5432Environment=PGDATA=/var/lib/pgsql/dataOOMScoreAdjust=-1000ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA}ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300ExecStop=/usr/bin/pg_ctl stop -D ${PGDATA} -s -m fastExecReload=/usr/bin/pg_ctl reload -D ${PGDATA} -sTimeoutSec=300

[Install]WantedBy=multi-user.target

Page 19: Systemd mlug-20140614

some systemd unit types:

service: traditional daemon (ssh, http, kdm...)socket: listener socket for service activationtarget: like a runlevel, but not exclusive

Page 20: Systemd mlug-20140614

no /etc/inittab:

/etc/systemd/system/default.target

is a symlink to e.g.

/lib/systemd/system/graphical.target

Page 21: Systemd mlug-20140614

some distros use symlinks:

runlevel0.target -> poweroff.targetrunlevel1.target -> rescue.targetrunlevel2.target -> multi-user.targetrunlevel3.target -> multi-user.targetrunlevel4.target -> multi-user.targetrunlevel5.target -> graphical.targetrunlevel6.target -> reboot.target

Page 22: Systemd mlug-20140614

more unit types:

slice: resource control via cgroups(can control CPU share, memory usage, IO bandwidth,device access)

snapshot: saves current runtime state,can return to it with isolate(lost on reboot)

Page 23: Systemd mlug-20140614

more unit types:

device: when device is ready (udev)mount: (/etc/fstab still preferred)automount: (requires matching mount unit)swap: swap spacepath: unit activation on path changetimer: event based on boot time,

time since a unit's activation,calendar time

Page 24: Systemd mlug-20140614

sysvinit compatibility

“virtual” service units created in-memorylook for LSB: or SYSV: in the output of systemd list-units

service,chkconfig,telinit... still work

for more information:freedesktop.org/wiki/Software/systemd/Incompatibilities/

Page 25: Systemd mlug-20140614

Usage

Page 26: Systemd mlug-20140614

GUI front-end for systemd:

systemadm

On Fedora 20 and OpenSUSE 13.1, installsystemd-ui package.

Good for exploring and learning systemd.

Page 27: Systemd mlug-20140614
Page 28: Systemd mlug-20140614

Most frequently-used commands:

systemctljournalctl

Completion prompting and color coding!

Page 29: Systemd mlug-20140614

systemctl [list-units]systemctl list-unit-filessystemctl -t servicesystemctl –-state failedsystemctl enable <servicename>systemctl start <servicename>systemctl status <servicename>systemctl daemon-reloadsystemctl halt

Page 30: Systemd mlug-20140614

journalctl -f (follow, like tail -f)journalctl -x (show extra)journalctl -n99 (last 99 entries)journalctl -b (since boot)journalctl -b -1 (since previous boot)journalctl --since (since date/time)journalctl -p err (by priority)journalctl -u (by unit)journalctl /usr/... (by executable)journalctl /dev/... (by device)

Page 31: Systemd mlug-20140614

switch “runlevel”:systemctl isolate <target-name>

emergency boot: start kernel withsystemd.unit=<target-name>

Page 32: Systemd mlug-20140614

systemd diagnostics:

systemd-cgls (“control group ls”)systemd-cgtop (“control group top”)

systemd-analyzesystemd-analyze blamesystemd-analyze plot > filename.svgsystemd-analyze dot | \ dot -Tsvg > systemd.svg

Page 33: Systemd mlug-20140614
Page 34: Systemd mlug-20140614

Example

Page 35: Systemd mlug-20140614
Page 36: Systemd mlug-20140614
Page 37: Systemd mlug-20140614
Page 38: Systemd mlug-20140614
Page 39: Systemd mlug-20140614
Page 40: Systemd mlug-20140614
Page 41: Systemd mlug-20140614
Page 42: Systemd mlug-20140614

resources:

overview:http://www.freedesktop.org/wiki/Software/systemd/

“Demystifying systemd” slides:http://bit.ly/1jm87CJ

“Getting Ready for Systemd” video:https://access.redhat.com/site/videos/403833


Recommended