SlideShare a Scribd company logo
1 of 43
Download to read offline
RHEL 7 Update 
systemd 
July 2014 
1 RED HAT | Ingo Börnig
OVERVIEW 
● RHEL 7.0 will ship with systemd, a new init system that replaces 
upstart. 
● But systemd is more then a SysVinit/upstart replacement 
● It is a system and service manager for Linux. 
● It can work as a drop-in replacement for sysvinit. 
● It replaces inetd and xinetd for most scenarios 
# ps ­­pid 
1 
PID TTY TIME CMD 
1 ? 00:00:01 systemd 
2 RED HAT | Ingo Börnig
Key Concepts 
● UNITS: 
● Services, Sockets, 
● Devices, Mounts, Automounts, Swaps 
● Timers, Paths, 
● Targets, Snapshots 
● Slices 
● Unit/Service Dependency Tracking 
● Process tracking with Service information 
3 RED HAT | Ingo Börnig
Benefits 
● Dependency tracking for units and processes 
● No more (sleep 60; do something) loops 
● Properly kill daemons 
● Minimal boot times 
● Debuging – no early boot messages are lost 
● Easy to learn and backwards compatible. 
● Autospawn and Respawn for Services 
● Tight integration with cgroups, the default interface in the future 
4 RED HAT | Ingo Börnig
Systemd - Units 
● Naming convention is: name.type 
● httpd.service, sshd.socket, or dev-hugepages.mount 
● Service – Describe a daemon's type, execution, environment, 
and how it's monitored. 
● Socket – Endpoint for interprocess communication. File, 
network, or Unix sockets. 
● Target – Logical grouping of units. Replacement for runlevels. 
● Device – Automatically created by the kernel. Can be provided 
to services as dependents. 
● Mounts, automounts, swap – Monitor the mounting/unmounting 
of file systems. 
5 RED HAT | Ingo Börnig
Systemd - Units 
● Snapshots – save the state of units – useful for testing 
● Timers – Timer-based activation 
● Paths – Uses inotify to monitor a path 
● Slices – cgroup hierarchy for resource management. 
● Scopes – Organizational units that groups services' worker 
processes. 
6 RED HAT | Ingo Börnig
Systemd – Dependency Resolution 
● Example: 
● Wait for block device 
● Check fle system for device 
● Mount fle system 
● nfs-lock.service: 
● Requires=rpcbind.service network.target 
● After=network.target named.service rpcbind.service 
● Before=remote-fs-pre.target 
7 RED HAT | Ingo Börnig
What about my System-V init scripts? 
● systemd maintains 99% backwards compatibility with initscripts 
and the exceptions are well documented. 
● While we do encourage everyone to convert legacy scripts to 
service unit files, it's not a requirement. 
● Hint: we'll show you how to do this in a few minutes. 
● Incompatibilities are listed here: 
http://www.freedesktop.org/wiki/Software/systemd/Incompatibilities/ 
● Converting SysV Init Scripts: 
http://0pointer.de/blog/projects/systemd-for-admins-3.html 
8 RED HAT | Ingo Börnig
Faster Boot times 
● Lennart Poettering says that “Fast booting isn't the goal of 
systemd, it's a result of a well designed system.” 
● As virt/cloud demand continues, the desire for light-weight, 
reliable/resilient, and fast images grows. 
● A stripped down image can boot in ~2 seconds. 
● Less CPU cycles burned during the boot process 
● Important for highly dense and dynamic environments. 
● Even more important for containers. 
9 RED HAT | Ingo Börnig
The Basics: Managing Services 
10 RED HAT | Ingo Börnig
Managing Services - Unit Files 
● Via Init: 
● Init scripts are stored in /etc/init.d & called from /etc/rc* 
● Via systemd: 
● Maintainer files: /usr/lib/systemd/system/ 
● User modifcations: /etc/systemd/system/ 
● Note: unit files under /etc/ will take precedence over /usr 
11 RED HAT | Ingo Börnig
Managing Services - Start/Stop 
● Via Init: 
● $ service httpd {start,stop,restart,reload} 
● Via systemctl: 
● $ systemctl {start,stop,restart,reload} httpd.service 
● Notes: 
● systemctl places the “action” before the service name. 
● If a unit isn't specifed, .service is assumed. 
● systemctl start httpd == systemctl start httpd.service 
● Tab completion works great with systemctl, install bash-completion 
● systemctl can connect to remote hosts over SSH using “-H” 
12 RED HAT | Ingo Börnig
Managing Services - Status 
● Via Init: 
● $ service httpd status 
● Via systemctl: 
● $ systemctl status httpd.service 
● List loaded services: 
● systemctl -t service 
● List installed services: 
● systemctl list-unit-files -t service (similar to chkconfg --list) 
● View state: 
● systemctl --state failed 
13 RED HAT | Ingo Börnig
Managing Services - Enable/Disable 
● Via Init: 
● $ chkconfg httpd {on,off} 
● Via systemctl: 
● $ systemctl {enable, disable, mask, unmask} httpd.service 
● mask – “This will link these units to /dev/null, making it 
impossible to start them. This is a stronger version of disable, 
since it prohibits all kinds of activation of the unit, including 
manual activation. Use this option with care.” 
14 RED HAT | Ingo Börnig
Runlevels... 
gone. 
15 RED HAT | Ingo Börnig
What Runlevels? 
● Runlevels == Targets 
● “Runlevels” are exposed via target units 
● /etc/inittab is no longer used 
● Target names are more relevant: 
● multi-user.target vs. runlevel3 
● graphical.target vs. runlevel5 
● Set the default via: `systemctl enable graphical.target --force` 
● Change at run-time via: `systemctl isolate [target]` 
16 RED HAT | Ingo Börnig
Runlevel Names 
Runlevel Systemd Target Description 
0 poweroff.target, runlevel0.target System halt 
1 rescue.target, runlevel1.target Single user mode 
3 (2,4) multi-user.target, runlevel3.target Multi-user, non graphical 
5 graphical.target, runlevel5.target Multi-user, graphical 
6 reboot.target, runlevel6.target System reboot 
ls /lib/systemd/system/runlevel*target ­l 
lrwxrwxrwx. 1 root root 15 Jul 3 21:37 /lib/systemd/system/runlevel0.target ­> 
poweroff.target 
lrwxrwxrwx. 1 root root 13 Jul 3 21:37 /lib/systemd/system/runlevel1.target ­> 
rescue.target 
lrwxrwxrwx. 1 root root 17 Jul 3 21:37 /lib/systemd/system/runlevel2.target ­> 
multi­user. 
target 
lrwxrwxrwx. 1 root root 17 Jul 3 21:37 /lib/systemd/system/runlevel3.target ­> 
multi­user. 
target 
lrwxrwxrwx. 1 root root 17 Jul 3 21:37 /lib/systemd/system/runlevel4.target ­> 
multi­user. 
target 
lrwxrwxrwx. 1 root root 16 Jul 3 21:37 /lib/systemd/system/runlevel5.target ­> 
graphical.target 
lrwxrwxrwx. 1 root root 13 Jul 3 21:37 /lib/systemd/system/runlevel6.target ­> 
reboot.target 
17 RED HAT | Ingo Börnig
Customizing Service Unit Files 
18 RED HAT | Ingo Börnig
Customizing Service Unit Files 
● Unit files can be altered or extended by placing “drop-ins” under: 
/etc/systemd/system/foobar.service.d/*.conf 
● Changes are applied on top of maintainer unit files. 
# cat /etc/systemd/system/httpd.service.d/50­httpd. 
conf 
[Service] 
Restart=always 
StartLimitInterval=10 
StartLimitBurst=5 
StartLimitAction=reboot 
CPUShares=2048 
Nice=­10 
OOMScoreAdjust=­1000 
19 RED HAT | Ingo Börnig
Customizing Service Unit Files 
● Run `systemctl daemon-reload` after making changes to notify 
systemd 
● Drop-ins will be shown from `systemctl status` 
# systemctl status httpd.service 
httpd.service ­The 
Apache HTTP Server 
Loaded: loaded (/usr/lib/systemd/system/httpd.service; 
enabled) 
Drop­In: 
/etc/systemd/system/httpd.service.d 
└─50­httpd. 
conf 
20 RED HAT | Ingo Börnig
Customizing Service Unit Files - Tips! 
● Changes to unit files under /usr/lib/systemd/system/ could be 
overwritten by updates. DON'T DO IT! 
● /etc service files will take precedence over /usr 
● Simply delete the drop-in to revert to defaults. Don't forget to run 
`systemctl daemon-reload` 
● systemd-delta – will show what is overridden and extended 
between /usr & /etc. 
● man 5 systemd.service, man 5 systemd.exec 
21 RED HAT | Ingo Börnig
Resource Management 
22 RED HAT | Ingo Börnig
Making Cgroups Easier 
● View cgroup hierarchy via systemd-cgls 
● View usage stats via systemd-cgtop (use for tuning) 
● Default hierarchy 
● system.slice – contains system services 
● user.slice – contains user sessions 
● machine.slice – contains virtual machines and containers 
● Services can be promoted to their own slice if necessary. 
23 RED HAT | Ingo Börnig
Resource Management – Configuration 
● systemctl can configure and persist cgroup attributes 
● systemctl set-property httpd.service CPUShares=2048 
● Add --runtime to not persist the settings: 
● systemctl set-property --runtime httpd.service  CPUShares=2048 
● Alternatively settings can be placed in unit files 
● [Service] 
● CPUShares=2048 
24 RED HAT | Ingo Börnig
Converting Init Scripts 
25 RED HAT | Ingo Börnig
Remember what an init-file looks like? 
#!/bin/bash 
# 
# httpd Startup script for the Apache HTTP Server 
# 
# chkconfig: ­85 
15 
# description: The Apache HTTP Server is an efficient and extensible  
# server implementing the current HTTP standards. 
# processname: httpd 
# config: /etc/httpd/conf/httpd.conf 
# config: /etc/sysconfig/httpd 
# pidfile: /var/run/httpd/httpd.pid 
# 
### BEGIN INIT INFO 
# Provides: httpd 
# Required­Start: 
$local_fs $remote_fs $network $named 
# Required­Stop: 
$local_fs $remote_fs $network 
# Should­Start: 
distcache 
# Short­Description: 
start and stop Apache HTTP Server 
# Description: The Apache HTTP Server is an extensible server 
# implementing the current HTTP standards. 
### END INIT INFO 
# Source function library. 
. /etc/rc.d/init.d/functions 
if [ ­f 
/etc/sysconfig/httpd ]; then 
. /etc/sysconfig/httpd 
fi 
# Start httpd in the C locale by default. 
HTTPD_LANG=${HTTPD_LANG­" 
C"} 
# This will prevent initlog from swallowing up a pass­phrase 
prompt if 
# mod_ssl needs a pass­phrase 
from the user. 
INITLOG_ARGS="" 
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server 
# with the thread­based 
"worker" MPM; BE WARNED that some modules may not 
# work correctly with a thread­based 
MPM; notably PHP will refuse to start. 
26 RED HAT | Ingo Börnig
# Path to the apachectl script, server binary, and short­form 
for messages. 
apachectl=/usr/sbin/apachectl 
httpd=${HTTPD­/ 
usr/sbin/httpd} 
prog=httpd 
pidfile=${PIDFILE­/ 
var/run/httpd/httpd.pid} 
lockfile=${LOCKFILE­/ 
var/lock/subsys/httpd} 
RETVAL=0 
STOP_TIMEOUT=${STOP_TIMEOUT­10} 
# check for 1.3 configuration 
check13 () { 
CONFFILE=/etc/httpd/conf/httpd.conf 
GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|" 
GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|" 
GONE="${GONE}AccessConfig|ResourceConfig)" 
if LANG=C grep ­Eiq 
"^[[:space:]]*($GONE)" $CONFFILE; then 
echo 
echo 1>&2 " Apache 1.3 configuration directives found" 
echo 1>&2 " please read /usr/share/doc/httpd­2.2.22/ 
migration.html" 
failure "Apache 1.3 config directives test" 
echo 
exit 1 
fi 
} 
# The semantics of these two functions differ from the way apachectl does 
# things ­­attempting 
to start while running is a failure, and shutdown 
# when not running is also a failure. So we just do it the way init scripts 
# are expected to behave here. 
start() { 
echo ­n 
$"Starting $prog: " 
check13 || exit 1 
LANG=$HTTPD_LANG daemon ­­pidfile=${ 
pidfile} $httpd $OPTIONS 
RETVAL=$? 
echo 
[ $RETVAL = 0 ] && touch ${lockfile} 
return $RETVAL 
} 
27 RED HAT | Ingo Börnig
# When stopping httpd, a delay (of default 10 second) is required 
# before SIGKILLing the httpd parent; this gives enough time for the 
# httpd parent to SIGKILL any errant children. 
stop() { 
echo ­n 
$"Stopping $prog: " 
killproc ­p 
${pidfile} ­d 
${STOP_TIMEOUT} $httpd 
RETVAL=$? 
echo 
[ $RETVAL = 0 ] && rm ­f 
${lockfile} ${pidfile} 
} 
reload() { 
echo ­n 
$"Reloading $prog: " 
if ! LANG=$HTTPD_LANG $httpd $OPTIONS ­t 
>&/dev/null; then 
RETVAL=6 
echo $"not reloading due to configuration syntax error" 
failure $"not reloading $httpd due to configuration syntax error" 
else 
# Force LSB behaviour from killproc 
LSB=1 killproc ­p 
${pidfile} $httpd ­HUP 
RETVAL=$? 
if [ $RETVAL ­eq 
7 ]; then 
failure $"httpd shutdown" 
fi 
fi 
echo 
} 
# See how we were called. 
case "$1" in 
start) 
start 
;; 
stop) 
stop 
;; 
status) 
status ­p 
${pidfile} $httpd 
RETVAL=$? 
;; 
restart) 
stop 
start 
;; 
28 RED HAT | Ingo Börnig
condrestart|try­restart) 
if status ­p 
${pidfile} $httpd >&/dev/null; then 
stop 
start 
fi 
;; 
force-reload|reload) 
reload 
;; 
graceful|help|configtest|fullstatus) 
$apachectl $@ 
RETVAL=$? 
;; 
*) 
echo $"Usage: $prog {start|stop|restart|condrestart|try­restart| 
force­reload| 
reload|status|fullstatus|graceful|help|configtest}" 
RETVAL=2 
esac 
exit $RETVAL 
29 RED HAT | Ingo Börnig
Contrast that with a systemd unit file syntax 
[Unit] 
Description=The Apache HTTP Server 
After=network.target remote­fs. 
target nss­lookup. 
target 
[Service] 
Type=notify 
EnvironmentFile=/etc/sysconfig/httpd 
ExecStart=/usr/sbin/httpd $OPTIONS ­DFOREGROUND 
ExecReload=/usr/sbin/httpd $OPTIONS ­k 
graceful 
ExecStop=/usr/sbin/httpd $OPTIONS ­k 
graceful­stop 
KillSignal=SIGCONT 
PrivateTmp=true 
[Install] 
WantedBy=multi­user. 
target 
30 RED HAT | Ingo Börnig
Test Unit File 
● Copy the unit file 
● cp [myapp].service /etc/systemd/system/ 
● Alert systemd of the changes: 
● systemctl daemon-reload 
● Start service 
● systemctl start [myapp].service 
● View status 
● systemctl status [myapp].service 
31 RED HAT | Ingo Börnig
The Journal 
32 RED HAT | Ingo Börnig
The Journal - Logging with systemd 
● “The journal is a component of systemd, that captures Syslog 
messages, Kernel log messages, initial RAM disk and early boot 
messages as well as messages written to STDOUT/STDERR of 
all services, indexes them and makes this available to the user” 
● Indexed 
● Formatted 
● Errors in red 
● Warnings in bold 
● Security 
● Reliability 
● Intelligently rotated 
33 RED HAT | Ingo Börnig
Journal 
● Does not replace rsyslog in RHEL 7 
● rsyslog is enabled by default 
● Use rsyslog for traditional logging w/ enterprise features 
● The journal is not persistent by default at the moment but a 
ring-buffer in /run/log/journal. 
● Collects event metadata 
● Stored in key-value pairs 
● man page: systemd.journal-felds(7) 
● journalctl - utility for to viewing the journal. 
● Simple (or complex) fltering 
● Interleave units, binaries, etc 
34 RED HAT | Ingo Börnig
Using the Journal 
● Enable persistence: `mkdir /var/log/journal` 
● View from boot: `journalctl -b` 
● Tail -f and -n work as expected: 
● journalctl -f ; journalctl -n 50 
● Filter by priority: `journalctl -p [level]` 
0 emerg 
1 alert 
2 crit 
3 err 
4 warning 
5 notice 
6 debug 
35 RED HAT | Ingo Börnig
Using the Journal 
● Other useful filters: 
● --since=yesterday or YYYY-MM-DD (HH:MM:SS) 
● --until=YYYY-MM-DD 
● -u [unit] 
● Pass binary e.g. /usr/sbin/dnsmasq 
● View journal felds 
● journalctl [tab] [tab]←bash-completion rocks!! 
● Entire journal 
● journalctl -o verbose (useful for grep) 
36 RED HAT | Ingo Börnig
Troubleshooting the Boot Process 
37 RED HAT | Ingo Börnig
Booting 
● Boot process is too fast, interactive boot append: 
systemd.confirm_spawn=1 
● /var/log/boot.log – still works the same 
● Enable debugging from grub by appending: 
● systemd.log_level=debug systemd.log_target=kmsg 
log_buf_len=1M 
● Or send dbug info to a serial console: systemd.log_level=debug 
systemd.log_target=console console=ttyS0 
● Enable early boot shell on tty9 
● systemctl enable debug-shell.service 
● ln -s /usr/lib/systemd/system/debug-shell.service  
/etc/systemd/system/sysinit.target.wants/ 
● systemctl list-jobs 
38 RED HAT | Ingo Börnig
Resource Management 
39 RED HAT | Ingo Börnig
Control Groups Made Simple 
Resource Management with cgroups can reduce application or VM 
contention and improve throughput and predictability 
40 RED HAT | Ingo Börnig
Slices, Scopes, Services 
● In RHEL7 systemd manages cgroups, new concept of 
Scopes/Slices: 
● Slice – Unit type for creating the cgroup hierarchy for resource 
management. 
● Scope – Organizational unit that groups a services' worker 
processes. 
● Service – Process or group of processes controlled by systemd 
41 RED HAT | Ingo Börnig
Control Groups - Usability Improvements: Scopes 
Systemd puts all related worker PIDs into cgroup called a ‘scope’. 
● Services 
● Apache processes in same services/apache scope 
● Mysql processes in same services/Mysql scope 
● Apache/Mysql get an equal “slice” of the system 
● Users accounts 
● All users get an equal “slice” 
● Machines 
● All containers/VMs get an equal “slice” 
● No service/user/machine can dominate system 
42 RED HAT | Ingo Börnig
Control Groups - Usability Improvements: Slices 
Special unit file for assigning resource constraints 
Slices get assigned to scopes 
● Systemd automatically assigns services to system.slice 
● You can override resource with Unit file configuration 
● MemoryLimit=1g 
● Command Line 
● #> systemctl set-property httpd.service CPUShares=524 
MemoryLimit=500M 
● Systemd will assign Containers to machine.slice 
● You can override by editing 
● /etc/systemd/system/big-machine.slice 
43 RED HAT | Ingo Börnig

More Related Content

What's hot

What's hot (20)

LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager
 
Introduction to systemd
Introduction to systemdIntroduction to systemd
Introduction to systemd
 
Systemd for developers
Systemd for developersSystemd for developers
Systemd for developers
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to love
 
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawn
 
SystemV vs systemd
SystemV vs systemdSystemV vs systemd
SystemV vs systemd
 
First steps on CentOs7
First steps on CentOs7First steps on CentOs7
First steps on CentOs7
 
Basic of Systemd
Basic of SystemdBasic of Systemd
Basic of Systemd
 
Rhel6 vs rhel7
Rhel6 vs rhel7Rhel6 vs rhel7
Rhel6 vs rhel7
 
Systemd cheatsheet
Systemd cheatsheetSystemd cheatsheet
Systemd cheatsheet
 
Linux Du Jour
Linux Du JourLinux Du Jour
Linux Du Jour
 
Tuning systemd for embedded
Tuning systemd for embeddedTuning systemd for embedded
Tuning systemd for embedded
 
Linux Containers From Scratch
Linux Containers From ScratchLinux Containers From Scratch
Linux Containers From Scratch
 
Linux Containers From Scratch: Makfile MicroVPS
Linux Containers From Scratch: Makfile MicroVPSLinux Containers From Scratch: Makfile MicroVPS
Linux Containers From Scratch: Makfile MicroVPS
 
Kernel Recipes 2015 - Porting Linux to a new processor architecture
Kernel Recipes 2015 - Porting Linux to a new processor architectureKernel Recipes 2015 - Porting Linux to a new processor architecture
Kernel Recipes 2015 - Porting Linux to a new processor architecture
 
Kernel Recipes 2015 - Kernel dump analysis
Kernel Recipes 2015 - Kernel dump analysisKernel Recipes 2015 - Kernel dump analysis
Kernel Recipes 2015 - Kernel dump analysis
 
Kdump and the kernel crash dump analysis
Kdump and the kernel crash dump analysisKdump and the kernel crash dump analysis
Kdump and the kernel crash dump analysis
 
Linux Kernel Debugging Essentials workshop
Linux Kernel Debugging Essentials workshopLinux Kernel Debugging Essentials workshop
Linux Kernel Debugging Essentials workshop
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Linux con europe_2014_f
Linux con europe_2014_fLinux con europe_2014_f
Linux con europe_2014_f
 

Viewers also liked

Viewers also liked (18)

Getting the maximum out of systemd
Getting the maximum out of systemdGetting the maximum out of systemd
Getting the maximum out of systemd
 
London open stack meet up - nov 2015
London open stack meet up - nov 2015London open stack meet up - nov 2015
London open stack meet up - nov 2015
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
 
systemd and configuration management
systemd and configuration managementsystemd and configuration management
systemd and configuration management
 
Enterprise Linux 7 new feature_systemd_booting
Enterprise Linux 7 new feature_systemd_bootingEnterprise Linux 7 new feature_systemd_booting
Enterprise Linux 7 new feature_systemd_booting
 
Kickstart, Puppet, Docker
Kickstart, Puppet, DockerKickstart, Puppet, Docker
Kickstart, Puppet, Docker
 
Code4vn - Linux day - linux boot process
Code4vn - Linux day - linux boot processCode4vn - Linux day - linux boot process
Code4vn - Linux day - linux boot process
 
How to Manage journalctl Logging System on RHEL 7
How to Manage journalctl Logging System on RHEL 7How to Manage journalctl Logging System on RHEL 7
How to Manage journalctl Logging System on RHEL 7
 
How To Manage Services on RHEL 7 or CentOS 7
How To Manage Services on RHEL 7 or CentOS 7How To Manage Services on RHEL 7 or CentOS 7
How To Manage Services on RHEL 7 or CentOS 7
 
How To Install and Configure Log Rotation on RHEL 7 or CentOS 7
How To Install and Configure Log Rotation on RHEL 7 or CentOS 7How To Install and Configure Log Rotation on RHEL 7 or CentOS 7
How To Install and Configure Log Rotation on RHEL 7 or CentOS 7
 
LSOF Command Usage on RHEL 7
LSOF Command Usage on RHEL 7LSOF Command Usage on RHEL 7
LSOF Command Usage on RHEL 7
 
How To Configure Apache VirtualHost on RHEL 7 on AWS
How To Configure Apache VirtualHost on RHEL 7 on AWSHow To Configure Apache VirtualHost on RHEL 7 on AWS
How To Configure Apache VirtualHost on RHEL 7 on AWS
 
How To Install and Generate Audit Reports in CentOS 7 or RHEL 7
How To Install and Generate Audit Reports in CentOS 7 or RHEL 7How To Install and Generate Audit Reports in CentOS 7 or RHEL 7
How To Install and Generate Audit Reports in CentOS 7 or RHEL 7
 
How To Install and Configure SNMP on RHEL 7 or CentOS 7
How To Install and Configure SNMP on RHEL 7 or CentOS 7How To Install and Configure SNMP on RHEL 7 or CentOS 7
How To Install and Configure SNMP on RHEL 7 or CentOS 7
 
SystemD Usage Guide
SystemD Usage GuideSystemD Usage Guide
SystemD Usage Guide
 
How To Install and Configure Chrony on RHEL 7
How To Install and Configure Chrony on RHEL 7How To Install and Configure Chrony on RHEL 7
How To Install and Configure Chrony on RHEL 7
 
Epoll - from the kernel side
Epoll -  from the kernel sideEpoll -  from the kernel side
Epoll - from the kernel side
 
How To Manage Linux User on RHEL 7
How To Manage Linux User on RHEL 7How To Manage Linux User on RHEL 7
How To Manage Linux User on RHEL 7
 

Similar to Pdf c1t tlawaxb

A3Sec Advanced Deployment System
A3Sec Advanced Deployment SystemA3Sec Advanced Deployment System
A3Sec Advanced Deployment System
a3sec
 
Automation@Brainly - Polish Linux Autumn 2014
Automation@Brainly - Polish Linux Autumn 2014Automation@Brainly - Polish Linux Autumn 2014
Automation@Brainly - Polish Linux Autumn 2014
vespian_256
 
Steps to build and run oai
Steps to build and run oaiSteps to build and run oai
Steps to build and run oai
ssuser38b887
 

Similar to Pdf c1t tlawaxb (20)

SHARE.ORG Orlando 2015
SHARE.ORG Orlando 2015SHARE.ORG Orlando 2015
SHARE.ORG Orlando 2015
 
A3Sec Advanced Deployment System
A3Sec Advanced Deployment SystemA3Sec Advanced Deployment System
A3Sec Advanced Deployment System
 
SCM Puppet: from an intro to the scaling
SCM Puppet: from an intro to the scalingSCM Puppet: from an intro to the scaling
SCM Puppet: from an intro to the scaling
 
Linux : Booting and runlevels
Linux : Booting and runlevelsLinux : Booting and runlevels
Linux : Booting and runlevels
 
Automation@Brainly - Polish Linux Autumn 2014
Automation@Brainly - Polish Linux Autumn 2014Automation@Brainly - Polish Linux Autumn 2014
Automation@Brainly - Polish Linux Autumn 2014
 
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios CoreNagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
 
Red Hat Summit 2018 5 New High Performance Features in OpenShift
Red Hat Summit 2018 5 New High Performance Features in OpenShiftRed Hat Summit 2018 5 New High Performance Features in OpenShift
Red Hat Summit 2018 5 New High Performance Features in OpenShift
 
Linux Server Deep Dives (DrupalCon Amsterdam)
Linux Server Deep Dives (DrupalCon Amsterdam)Linux Server Deep Dives (DrupalCon Amsterdam)
Linux Server Deep Dives (DrupalCon Amsterdam)
 
Steps to build and run oai
Steps to build and run oaiSteps to build and run oai
Steps to build and run oai
 
ChinaNetCloud Training - iptables Intro
ChinaNetCloud Training - iptables IntroChinaNetCloud Training - iptables Intro
ChinaNetCloud Training - iptables Intro
 
Tuned
TunedTuned
Tuned
 
Tuned
TunedTuned
Tuned
 
Cloud firewall logging
Cloud firewall loggingCloud firewall logging
Cloud firewall logging
 
Automotive Grade Linux and systemd
Automotive Grade Linux and systemdAutomotive Grade Linux and systemd
Automotive Grade Linux and systemd
 
Workflow story: Theory versus Practice in large enterprises by Marcin Piebiak
Workflow story: Theory versus Practice in large enterprises by Marcin PiebiakWorkflow story: Theory versus Practice in large enterprises by Marcin Piebiak
Workflow story: Theory versus Practice in large enterprises by Marcin Piebiak
 
Workflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large EnterprisesWorkflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large Enterprises
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
The Domino 10 RHEL 7 Primer
The Domino 10 RHEL 7 PrimerThe Domino 10 RHEL 7 Primer
The Domino 10 RHEL 7 Primer
 
Pluggable Infrastructure with CI/CD and Docker
Pluggable Infrastructure with CI/CD and DockerPluggable Infrastructure with CI/CD and Docker
Pluggable Infrastructure with CI/CD and Docker
 
Optimizing Linux Servers
Optimizing Linux ServersOptimizing Linux Servers
Optimizing Linux Servers
 

More from Susant Sahani

More from Susant Sahani (20)

systemd
systemdsystemd
systemd
 
systemd
systemdsystemd
systemd
 
How to debug systemd problems fedora project
How to debug systemd problems   fedora projectHow to debug systemd problems   fedora project
How to debug systemd problems fedora project
 
Systemd vs-sys vinit-cheatsheet.jpg
Systemd vs-sys vinit-cheatsheet.jpgSystemd vs-sys vinit-cheatsheet.jpg
Systemd vs-sys vinit-cheatsheet.jpg
 
Systemd
SystemdSystemd
Systemd
 
Systemd for administrators
Systemd for administratorsSystemd for administrators
Systemd for administrators
 
Systemd for administrators
Systemd for administratorsSystemd for administrators
Systemd for administrators
 
Interface between kernel and user space
Interface between kernel and user spaceInterface between kernel and user space
Interface between kernel and user space
 
Week3 binary trees
Week3 binary treesWeek3 binary trees
Week3 binary trees
 
Van jaconson netchannels
Van jaconson netchannelsVan jaconson netchannels
Van jaconson netchannels
 
Trees
TreesTrees
Trees
 
Synchronization linux
Synchronization linuxSynchronization linux
Synchronization linux
 
Demo preorder-stack
Demo preorder-stackDemo preorder-stack
Demo preorder-stack
 
Bacnet white paper
Bacnet white paperBacnet white paper
Bacnet white paper
 
Api presentation
Api presentationApi presentation
Api presentation
 
How to-simulate-network-devices
How to-simulate-network-devicesHow to-simulate-network-devices
How to-simulate-network-devices
 
L kernel-logging-apis-pdf
L kernel-logging-apis-pdfL kernel-logging-apis-pdf
L kernel-logging-apis-pdf
 
Introduction to freebsd_6_kernel_hacking
Introduction to freebsd_6_kernel_hackingIntroduction to freebsd_6_kernel_hacking
Introduction to freebsd_6_kernel_hacking
 
Www.dedoimedo.com crash-book
Www.dedoimedo.com crash-bookWww.dedoimedo.com crash-book
Www.dedoimedo.com crash-book
 
Sctp tutorial
Sctp tutorialSctp tutorial
Sctp tutorial
 

Recently uploaded

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

Pdf c1t tlawaxb

  • 1. RHEL 7 Update systemd July 2014 1 RED HAT | Ingo Börnig
  • 2. OVERVIEW ● RHEL 7.0 will ship with systemd, a new init system that replaces upstart. ● But systemd is more then a SysVinit/upstart replacement ● It is a system and service manager for Linux. ● It can work as a drop-in replacement for sysvinit. ● It replaces inetd and xinetd for most scenarios # ps ­­pid 1 PID TTY TIME CMD 1 ? 00:00:01 systemd 2 RED HAT | Ingo Börnig
  • 3. Key Concepts ● UNITS: ● Services, Sockets, ● Devices, Mounts, Automounts, Swaps ● Timers, Paths, ● Targets, Snapshots ● Slices ● Unit/Service Dependency Tracking ● Process tracking with Service information 3 RED HAT | Ingo Börnig
  • 4. Benefits ● Dependency tracking for units and processes ● No more (sleep 60; do something) loops ● Properly kill daemons ● Minimal boot times ● Debuging – no early boot messages are lost ● Easy to learn and backwards compatible. ● Autospawn and Respawn for Services ● Tight integration with cgroups, the default interface in the future 4 RED HAT | Ingo Börnig
  • 5. Systemd - Units ● Naming convention is: name.type ● httpd.service, sshd.socket, or dev-hugepages.mount ● Service – Describe a daemon's type, execution, environment, and how it's monitored. ● Socket – Endpoint for interprocess communication. File, network, or Unix sockets. ● Target – Logical grouping of units. Replacement for runlevels. ● Device – Automatically created by the kernel. Can be provided to services as dependents. ● Mounts, automounts, swap – Monitor the mounting/unmounting of file systems. 5 RED HAT | Ingo Börnig
  • 6. Systemd - Units ● Snapshots – save the state of units – useful for testing ● Timers – Timer-based activation ● Paths – Uses inotify to monitor a path ● Slices – cgroup hierarchy for resource management. ● Scopes – Organizational units that groups services' worker processes. 6 RED HAT | Ingo Börnig
  • 7. Systemd – Dependency Resolution ● Example: ● Wait for block device ● Check fle system for device ● Mount fle system ● nfs-lock.service: ● Requires=rpcbind.service network.target ● After=network.target named.service rpcbind.service ● Before=remote-fs-pre.target 7 RED HAT | Ingo Börnig
  • 8. What about my System-V init scripts? ● systemd maintains 99% backwards compatibility with initscripts and the exceptions are well documented. ● While we do encourage everyone to convert legacy scripts to service unit files, it's not a requirement. ● Hint: we'll show you how to do this in a few minutes. ● Incompatibilities are listed here: http://www.freedesktop.org/wiki/Software/systemd/Incompatibilities/ ● Converting SysV Init Scripts: http://0pointer.de/blog/projects/systemd-for-admins-3.html 8 RED HAT | Ingo Börnig
  • 9. Faster Boot times ● Lennart Poettering says that “Fast booting isn't the goal of systemd, it's a result of a well designed system.” ● As virt/cloud demand continues, the desire for light-weight, reliable/resilient, and fast images grows. ● A stripped down image can boot in ~2 seconds. ● Less CPU cycles burned during the boot process ● Important for highly dense and dynamic environments. ● Even more important for containers. 9 RED HAT | Ingo Börnig
  • 10. The Basics: Managing Services 10 RED HAT | Ingo Börnig
  • 11. Managing Services - Unit Files ● Via Init: ● Init scripts are stored in /etc/init.d & called from /etc/rc* ● Via systemd: ● Maintainer files: /usr/lib/systemd/system/ ● User modifcations: /etc/systemd/system/ ● Note: unit files under /etc/ will take precedence over /usr 11 RED HAT | Ingo Börnig
  • 12. Managing Services - Start/Stop ● Via Init: ● $ service httpd {start,stop,restart,reload} ● Via systemctl: ● $ systemctl {start,stop,restart,reload} httpd.service ● Notes: ● systemctl places the “action” before the service name. ● If a unit isn't specifed, .service is assumed. ● systemctl start httpd == systemctl start httpd.service ● Tab completion works great with systemctl, install bash-completion ● systemctl can connect to remote hosts over SSH using “-H” 12 RED HAT | Ingo Börnig
  • 13. Managing Services - Status ● Via Init: ● $ service httpd status ● Via systemctl: ● $ systemctl status httpd.service ● List loaded services: ● systemctl -t service ● List installed services: ● systemctl list-unit-files -t service (similar to chkconfg --list) ● View state: ● systemctl --state failed 13 RED HAT | Ingo Börnig
  • 14. Managing Services - Enable/Disable ● Via Init: ● $ chkconfg httpd {on,off} ● Via systemctl: ● $ systemctl {enable, disable, mask, unmask} httpd.service ● mask – “This will link these units to /dev/null, making it impossible to start them. This is a stronger version of disable, since it prohibits all kinds of activation of the unit, including manual activation. Use this option with care.” 14 RED HAT | Ingo Börnig
  • 15. Runlevels... gone. 15 RED HAT | Ingo Börnig
  • 16. What Runlevels? ● Runlevels == Targets ● “Runlevels” are exposed via target units ● /etc/inittab is no longer used ● Target names are more relevant: ● multi-user.target vs. runlevel3 ● graphical.target vs. runlevel5 ● Set the default via: `systemctl enable graphical.target --force` ● Change at run-time via: `systemctl isolate [target]` 16 RED HAT | Ingo Börnig
  • 17. Runlevel Names Runlevel Systemd Target Description 0 poweroff.target, runlevel0.target System halt 1 rescue.target, runlevel1.target Single user mode 3 (2,4) multi-user.target, runlevel3.target Multi-user, non graphical 5 graphical.target, runlevel5.target Multi-user, graphical 6 reboot.target, runlevel6.target System reboot ls /lib/systemd/system/runlevel*target ­l lrwxrwxrwx. 1 root root 15 Jul 3 21:37 /lib/systemd/system/runlevel0.target ­> poweroff.target lrwxrwxrwx. 1 root root 13 Jul 3 21:37 /lib/systemd/system/runlevel1.target ­> rescue.target lrwxrwxrwx. 1 root root 17 Jul 3 21:37 /lib/systemd/system/runlevel2.target ­> multi­user. target lrwxrwxrwx. 1 root root 17 Jul 3 21:37 /lib/systemd/system/runlevel3.target ­> multi­user. target lrwxrwxrwx. 1 root root 17 Jul 3 21:37 /lib/systemd/system/runlevel4.target ­> multi­user. target lrwxrwxrwx. 1 root root 16 Jul 3 21:37 /lib/systemd/system/runlevel5.target ­> graphical.target lrwxrwxrwx. 1 root root 13 Jul 3 21:37 /lib/systemd/system/runlevel6.target ­> reboot.target 17 RED HAT | Ingo Börnig
  • 18. Customizing Service Unit Files 18 RED HAT | Ingo Börnig
  • 19. Customizing Service Unit Files ● Unit files can be altered or extended by placing “drop-ins” under: /etc/systemd/system/foobar.service.d/*.conf ● Changes are applied on top of maintainer unit files. # cat /etc/systemd/system/httpd.service.d/50­httpd. conf [Service] Restart=always StartLimitInterval=10 StartLimitBurst=5 StartLimitAction=reboot CPUShares=2048 Nice=­10 OOMScoreAdjust=­1000 19 RED HAT | Ingo Börnig
  • 20. Customizing Service Unit Files ● Run `systemctl daemon-reload` after making changes to notify systemd ● Drop-ins will be shown from `systemctl status` # systemctl status httpd.service httpd.service ­The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled) Drop­In: /etc/systemd/system/httpd.service.d └─50­httpd. conf 20 RED HAT | Ingo Börnig
  • 21. Customizing Service Unit Files - Tips! ● Changes to unit files under /usr/lib/systemd/system/ could be overwritten by updates. DON'T DO IT! ● /etc service files will take precedence over /usr ● Simply delete the drop-in to revert to defaults. Don't forget to run `systemctl daemon-reload` ● systemd-delta – will show what is overridden and extended between /usr & /etc. ● man 5 systemd.service, man 5 systemd.exec 21 RED HAT | Ingo Börnig
  • 22. Resource Management 22 RED HAT | Ingo Börnig
  • 23. Making Cgroups Easier ● View cgroup hierarchy via systemd-cgls ● View usage stats via systemd-cgtop (use for tuning) ● Default hierarchy ● system.slice – contains system services ● user.slice – contains user sessions ● machine.slice – contains virtual machines and containers ● Services can be promoted to their own slice if necessary. 23 RED HAT | Ingo Börnig
  • 24. Resource Management – Configuration ● systemctl can configure and persist cgroup attributes ● systemctl set-property httpd.service CPUShares=2048 ● Add --runtime to not persist the settings: ● systemctl set-property --runtime httpd.service CPUShares=2048 ● Alternatively settings can be placed in unit files ● [Service] ● CPUShares=2048 24 RED HAT | Ingo Börnig
  • 25. Converting Init Scripts 25 RED HAT | Ingo Börnig
  • 26. Remember what an init-file looks like? #!/bin/bash # # httpd Startup script for the Apache HTTP Server # # chkconfig: ­85 15 # description: The Apache HTTP Server is an efficient and extensible # server implementing the current HTTP standards. # processname: httpd # config: /etc/httpd/conf/httpd.conf # config: /etc/sysconfig/httpd # pidfile: /var/run/httpd/httpd.pid # ### BEGIN INIT INFO # Provides: httpd # Required­Start: $local_fs $remote_fs $network $named # Required­Stop: $local_fs $remote_fs $network # Should­Start: distcache # Short­Description: start and stop Apache HTTP Server # Description: The Apache HTTP Server is an extensible server # implementing the current HTTP standards. ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions if [ ­f /etc/sysconfig/httpd ]; then . /etc/sysconfig/httpd fi # Start httpd in the C locale by default. HTTPD_LANG=${HTTPD_LANG­" C"} # This will prevent initlog from swallowing up a pass­phrase prompt if # mod_ssl needs a pass­phrase from the user. INITLOG_ARGS="" # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server # with the thread­based "worker" MPM; BE WARNED that some modules may not # work correctly with a thread­based MPM; notably PHP will refuse to start. 26 RED HAT | Ingo Börnig
  • 27. # Path to the apachectl script, server binary, and short­form for messages. apachectl=/usr/sbin/apachectl httpd=${HTTPD­/ usr/sbin/httpd} prog=httpd pidfile=${PIDFILE­/ var/run/httpd/httpd.pid} lockfile=${LOCKFILE­/ var/lock/subsys/httpd} RETVAL=0 STOP_TIMEOUT=${STOP_TIMEOUT­10} # check for 1.3 configuration check13 () { CONFFILE=/etc/httpd/conf/httpd.conf GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|" GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|" GONE="${GONE}AccessConfig|ResourceConfig)" if LANG=C grep ­Eiq "^[[:space:]]*($GONE)" $CONFFILE; then echo echo 1>&2 " Apache 1.3 configuration directives found" echo 1>&2 " please read /usr/share/doc/httpd­2.2.22/ migration.html" failure "Apache 1.3 config directives test" echo exit 1 fi } # The semantics of these two functions differ from the way apachectl does # things ­­attempting to start while running is a failure, and shutdown # when not running is also a failure. So we just do it the way init scripts # are expected to behave here. start() { echo ­n $"Starting $prog: " check13 || exit 1 LANG=$HTTPD_LANG daemon ­­pidfile=${ pidfile} $httpd $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL } 27 RED HAT | Ingo Börnig
  • 28. # When stopping httpd, a delay (of default 10 second) is required # before SIGKILLing the httpd parent; this gives enough time for the # httpd parent to SIGKILL any errant children. stop() { echo ­n $"Stopping $prog: " killproc ­p ${pidfile} ­d ${STOP_TIMEOUT} $httpd RETVAL=$? echo [ $RETVAL = 0 ] && rm ­f ${lockfile} ${pidfile} } reload() { echo ­n $"Reloading $prog: " if ! LANG=$HTTPD_LANG $httpd $OPTIONS ­t >&/dev/null; then RETVAL=6 echo $"not reloading due to configuration syntax error" failure $"not reloading $httpd due to configuration syntax error" else # Force LSB behaviour from killproc LSB=1 killproc ­p ${pidfile} $httpd ­HUP RETVAL=$? if [ $RETVAL ­eq 7 ]; then failure $"httpd shutdown" fi fi echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status ­p ${pidfile} $httpd RETVAL=$? ;; restart) stop start ;; 28 RED HAT | Ingo Börnig
  • 29. condrestart|try­restart) if status ­p ${pidfile} $httpd >&/dev/null; then stop start fi ;; force-reload|reload) reload ;; graceful|help|configtest|fullstatus) $apachectl $@ RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|try­restart| force­reload| reload|status|fullstatus|graceful|help|configtest}" RETVAL=2 esac exit $RETVAL 29 RED HAT | Ingo Börnig
  • 30. Contrast that with a systemd unit file syntax [Unit] Description=The Apache HTTP Server After=network.target remote­fs. target nss­lookup. target [Service] Type=notify EnvironmentFile=/etc/sysconfig/httpd ExecStart=/usr/sbin/httpd $OPTIONS ­DFOREGROUND ExecReload=/usr/sbin/httpd $OPTIONS ­k graceful ExecStop=/usr/sbin/httpd $OPTIONS ­k graceful­stop KillSignal=SIGCONT PrivateTmp=true [Install] WantedBy=multi­user. target 30 RED HAT | Ingo Börnig
  • 31. Test Unit File ● Copy the unit file ● cp [myapp].service /etc/systemd/system/ ● Alert systemd of the changes: ● systemctl daemon-reload ● Start service ● systemctl start [myapp].service ● View status ● systemctl status [myapp].service 31 RED HAT | Ingo Börnig
  • 32. The Journal 32 RED HAT | Ingo Börnig
  • 33. The Journal - Logging with systemd ● “The journal is a component of systemd, that captures Syslog messages, Kernel log messages, initial RAM disk and early boot messages as well as messages written to STDOUT/STDERR of all services, indexes them and makes this available to the user” ● Indexed ● Formatted ● Errors in red ● Warnings in bold ● Security ● Reliability ● Intelligently rotated 33 RED HAT | Ingo Börnig
  • 34. Journal ● Does not replace rsyslog in RHEL 7 ● rsyslog is enabled by default ● Use rsyslog for traditional logging w/ enterprise features ● The journal is not persistent by default at the moment but a ring-buffer in /run/log/journal. ● Collects event metadata ● Stored in key-value pairs ● man page: systemd.journal-felds(7) ● journalctl - utility for to viewing the journal. ● Simple (or complex) fltering ● Interleave units, binaries, etc 34 RED HAT | Ingo Börnig
  • 35. Using the Journal ● Enable persistence: `mkdir /var/log/journal` ● View from boot: `journalctl -b` ● Tail -f and -n work as expected: ● journalctl -f ; journalctl -n 50 ● Filter by priority: `journalctl -p [level]` 0 emerg 1 alert 2 crit 3 err 4 warning 5 notice 6 debug 35 RED HAT | Ingo Börnig
  • 36. Using the Journal ● Other useful filters: ● --since=yesterday or YYYY-MM-DD (HH:MM:SS) ● --until=YYYY-MM-DD ● -u [unit] ● Pass binary e.g. /usr/sbin/dnsmasq ● View journal felds ● journalctl [tab] [tab]←bash-completion rocks!! ● Entire journal ● journalctl -o verbose (useful for grep) 36 RED HAT | Ingo Börnig
  • 37. Troubleshooting the Boot Process 37 RED HAT | Ingo Börnig
  • 38. Booting ● Boot process is too fast, interactive boot append: systemd.confirm_spawn=1 ● /var/log/boot.log – still works the same ● Enable debugging from grub by appending: ● systemd.log_level=debug systemd.log_target=kmsg log_buf_len=1M ● Or send dbug info to a serial console: systemd.log_level=debug systemd.log_target=console console=ttyS0 ● Enable early boot shell on tty9 ● systemctl enable debug-shell.service ● ln -s /usr/lib/systemd/system/debug-shell.service /etc/systemd/system/sysinit.target.wants/ ● systemctl list-jobs 38 RED HAT | Ingo Börnig
  • 39. Resource Management 39 RED HAT | Ingo Börnig
  • 40. Control Groups Made Simple Resource Management with cgroups can reduce application or VM contention and improve throughput and predictability 40 RED HAT | Ingo Börnig
  • 41. Slices, Scopes, Services ● In RHEL7 systemd manages cgroups, new concept of Scopes/Slices: ● Slice – Unit type for creating the cgroup hierarchy for resource management. ● Scope – Organizational unit that groups a services' worker processes. ● Service – Process or group of processes controlled by systemd 41 RED HAT | Ingo Börnig
  • 42. Control Groups - Usability Improvements: Scopes Systemd puts all related worker PIDs into cgroup called a ‘scope’. ● Services ● Apache processes in same services/apache scope ● Mysql processes in same services/Mysql scope ● Apache/Mysql get an equal “slice” of the system ● Users accounts ● All users get an equal “slice” ● Machines ● All containers/VMs get an equal “slice” ● No service/user/machine can dominate system 42 RED HAT | Ingo Börnig
  • 43. Control Groups - Usability Improvements: Slices Special unit file for assigning resource constraints Slices get assigned to scopes ● Systemd automatically assigns services to system.slice ● You can override resource with Unit file configuration ● MemoryLimit=1g ● Command Line ● #> systemctl set-property httpd.service CPUShares=524 MemoryLimit=500M ● Systemd will assign Containers to machine.slice ● You can override by editing ● /etc/systemd/system/big-machine.slice 43 RED HAT | Ingo Börnig