Sie sind auf Seite 1von 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
History
init, the father of processes

BIOS loads bootloader ro! "ard dri#e

bootloader loads G$UB

G$UB loads kernel

kernel !ounts %les&ste!s and loads dri#ers

kernel starts %rst pro'ess (init)


sysvinit startup

init looks or deault runle#el and runs its


s'ripts to start t"e appropriate ser#i'es

ea'" runle#el "as a dire'tor& /etc/rcN.d/


wit" start and stop s&!links to s'ripts in
/etc/init.d
init systems
traditional* s&s#init (Linux)
alternate* Open$+ (Gentoo), upstart (Ubuntu)
ot"er OS* BS,, SM- (Solaris), laun'"d (Ma')
What's wrong with sysvinit?
s&n'"ronous
e#er&t"in. started at boot ti!e
'an/t 'ontrol double0orked '"ild pro'esses
What's better about systemd?
as&n'"ronous
ser#i'es started onl& w"en needed (#ia so'ket)
ser#i'es run in '.roups
Why is systemd controversial?
1do one t"in. and do it well2 (eature 'reep)
depends on dbus3kdbus
Linux0spe'i%' (be'ause o '.roups)
binar& lo. %le (t"e 4ournal)
http://0pointer.de/blog/projects/the-biggest-myths.html

Why is systemd controversial?
1do one t"in. and do it well2 (eature 'reep)
depends on dbus3kdbus
Linux0spe'i%' (be'ause o '.roups)
binar& lo. %le (t"e 4ournal)
http://0pointer.de/blog/projects/the-biggest-myths.html
personalit& 'on5i'ts666
systemd adoption
Ubuntu* upstart 2007 (nati#e init 2008)
-edora* upstart 2009, s&ste!d 2011
$:;L* $:;L < (4ust released) uses s&ste!d
SUS;* upstart option 2010, s&ste!d 2011
SL;S* SL;S 12 (=>) will use s&ste!d
,ebian* s&ste!d 2014, Ubuntu will ollow
echanics
Why is sysvinit synchronous?
ser#i'es wait or t"eir dependen'ies
(w"i'" open a so'ket w"en read&)
Why not open the soc!et on startup?
ser#i'es wit" dependen'ies 'an start at on'e
so'ket bu?er "olds !essa.es until read&
Why is sysvinit slow?
s"ell s'ripts@ (s"ell loaded o#er and o#er)
!ultiple in#o'ations o .rep, awk, sed666
Why not use con"guration "les?
in /usr/lib/systemd/system
lo'als, o#errides in /etc/systemd/system
[Unit]
Description=PostgreSQ d"t"b"se ser#er
$%ter=net&or'.t"rget
[Ser#ice]
(ype=%or'ing
User=postgres
)roup=postgres
*n#ironment=P)P+,(=-./0
*n#ironment=P)D$($=/#"r/lib/pgs1l/d"t"
++2Score$djust=-3000
*4ecSt"rtPre=/usr/bin/postgres1l-chec'-db-dir 56P)D$($7
*4ecSt"rt=/usr/bin/pg8ctl st"rt -D 56P)D$($7 -s -o
9-p 56P)P+,(79 -& -t /00
*4ecStop=/usr/bin/pg8ctl stop -D 56P)D$($7 -s -m %"st
*4ec,elo"d=/usr/bin/pg8ctl relo"d -D 56P)D$($7 -s
(imeoutSec=/00
[:nst"ll]
;"nted<y=multi-user.t"rget
some systemd unit types:
service: traditional dae!on (ss", "ttp, kd!666)
soc!et: listener so'ket or ser#i'e a'ti#ation
target: like a runle#el, but not ex'lusi#e
no #etc#inittab:
/etc/systemd/system/de%"ult.t"rget
is a symlin! to e$g$
/lib/systemd/system/gr"phic"l.t"rget
some distros use symlin!s:
runle#el0.t"rget -= po&ero%%.t"rget
runle#el3.t"rget -= rescue.t"rget
runle#el0.t"rget -= multi-user.t"rget
runle#el/.t"rget -= multi-user.t"rget
runle#el..t"rget -= multi-user.t"rget
runle#el-.t"rget -= gr"phic"l.t"rget
runle#el>.t"rget -= reboot.t"rget
more unit types:
slice: resour'e 'ontrol #ia '.roups
('an 'ontrol +AU s"are,
!e!or& usa.e, IO bandwidt",
de#i'e a''ess)
snapshot: sa#es 'urrent runti!e state,
'an return to it wit" isol"te
(lost on reboot)
more unit types:
device: w"en de#i'e is read& (ude#)
mount: (/etc/%st"b still preerred)
automount: (reBuires !at'"in. !ount unit)
swap: swap spa'e
path: unit a'ti#ation on pat" '"an.e
timer: e#ent based on boot ti!e,
ti!e sin'e a unit/s a'ti#ation,
'alendar ti!e
sysvinit compatibility
1#irtual2 ser#i'e units 'reated in0!e!or&
look or S<: or S?S@: in t"e output o
systemd list-units
ser#iceAch'con%igAtelinit... still work
or !ore inor!ation*
%reedes'top.org/&i'i/So%t&"re/systemd/:ncomp"tibilities/
%sage
G%& front'end for systemd:
system"dm
On -edora 20 and OpenSUS; 1>61, install
systemd-ui pa'ka.e6
Good or explorin. and learnin. s&ste!d6
ost fre(uently'used commands:
systemctl
journ"lctl
+o!pletion pro!ptin. and 'olor 'odin.@
systemctl [list-units]
systemctl list-unit-%iles
systemctl -t ser#ice
systemctl B-st"te %"iled
systemctl en"ble Cser#icen"me=
systemctl st"rt Cser#icen"me=
systemctl st"tus Cser#icen"me=
systemctl d"emon-relo"d
systemctl h"lt
journ"lctl -% )follow, li!e tail 'f*
journ"lctl -4 )show extra*
journ"lctl -nDD )last ++ entries*
journ"lctl -b )since boot*
journ"lctl -b -3 )since previous boot*
journ"lctl --since )since date#time*
journ"lctl -p err )by priority*
journ"lctl -u )by unit*
journ"lctl /usr/... )by executable*
journ"lctl /de#/... )by device*
switch ,runlevel-:
systemctl isol"te Ct"rget-n"me=
emergency boot: start !ernel with
systemd.unit=Ct"rget-n"me=
systemd diagnostics:
systemd-cgls ),control group ls-*
systemd-cgtop ),control group top-*
systemd-"n"lyEe
systemd-"n"lyEe bl"me
systemd-"n"lyEe plot = %ilen"me.s#g
systemd-"n"lyEe dot F G
dot -(s#g = systemd.s#g
.xample
resources:
o#er#iew*
http://&&&.%reedes'top.org/&i'i/So%t&"re/systemd/
1,e!&sti&in. s&ste!d2 slides*
http://bit.ly/3jmHIJK
1Gettin. $ead& or S&ste!d2 #ideo*
https://"ccess.redh"t.com/site/#ideos/.0/H//

Das könnte Ihnen auch gefallen