Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unified service management (and systemd)

Unified service management (and systemd)

The workshop is about service management and how to do it with systemd.

Service Management Big Picture:
What is there around:
The rise of systemd and unification of service management in Linux.
Service management vs. container management.
systemd Holy Wars, people with strong opinions and being pragmatic.

What is systemd?
Goal.
Pros, Cons.
Key concepts.

Get Job Done with systemd:
Reading logs.
"Cron jobs"
Autostarting services.
Autorestarting services.
Debugging.

Michael Pershyn

November 10, 2016
Tweet

More Decks by Michael Pershyn

Other Decks in Programming

Transcript

  1. 2 Agenda • Service Management Big Picture • What is

    systemd? • Get Job Done with systemd
  2. 3 Fragmentation Problem Assume you have lots of servers, some

    of them will run systemd, some may still run sysV init scripts, You have to know both
  3. 4

  4. 6 What is a service (OS) • A program that

    runs as a background process, rather than being under the direct control of an interactive user • In Unix-world knows as a daemon • In Microsoft-world known as a service
  5. 8 What is init? The init is a frst daemon

    process which starts as soon as the computer starts and continue running till, it is shutdown. It’s pid is 1.
  6. 10 Service Management in Linux • SysV init scripts –

    Not parallel, because of poor dependency management – Stable since 1982 (UNIX System V) – “Fire and forget”. But there are supervisord, runit and circus – Lots of missing features (see Links) • systemd – Widely adopted as drop-in replacement for SysV init scripts – Does much more than service management should do – Is a platform
  7. 12 Service Management vs. Container Orchestration Container Orchestration is about

    managing services running in containers Usually in a cloud
  8. 13 Container Orchestration Tools • Common tools for Container Orchestration

    – Kubernetes – Mesosphere Marathon – Docker Swarm – Amazon EC2 Container Service • It is also possible to manage services, running in containers on one host using systemctl
  9. 15 What is systemd? systemd is a service- and system

    manager, that replaces SysV init scripts and does a lot more
  10. 16 Goal/Features of systemd • Parallelized service execution, speedup the

    boot • Socket and D-Bus activation for starting services and daemon • On-demand starting of demons • Managing the service processes as a group using Linux cgroup (resource management) • Supporting automount points, snapshotting, and restoring of services • Manage logs, crons, locale, logins, time, network, ...
  11. 17 Pros • Systemd brings standardization • Unit Files replace

    init scripts and are much simpler to write and maintain. They are same and run then on every distribution that supports systemd • Faster startups and less services running due to efcient dependency resolution and concurrency • ...
  12. 18 Cons • Takes to many responsibilities • Binary logs

    (can be turned of) • Not the unix-way (small things that do one job) • Depends heavy on Linux API, not portable to GNU systems without Linux (hi hurd) and BSD Family • ...
  13. 20 systemd concepts • Unit - any resource that the

    system knows how to operate on and manage – E.g.: service, socket, device, timer, ... • Unit File – confguration fle, that defnes unit – Contains Sections and Directives • [Section] • DirectiveKey=DirectiveValue • Unit Files locations – /lib/systemd/system/* - default location, do not edit – /etc/systemd/system/* - best location for overrides – /run/systemd/system/* - for run-time unit defnitions
  14. 22 Reading logs • Logs are accessible through journalctl –

    sudo journalctl -u dmp-importer -f – sudo journalctl -u docker.service -f • journalctl takes care about logs, rotation and storage. It also drops old or massive ones when limits are reached • On debian, some are duplicated as plain text in /var/log/*
  15. 23 Cron-jobs • The cron jobs are replaced with .timer

    unit fle • To start d*ner.service daily, another unit is needed: d*ner.timer
  16. 26 Cheat sheet • Use one in the beginning More

    here: http://images.linoxide.com/systemd-vs-sysVinit-cheatsheet.pdf
  17. 27 Some useful links • The Debian developer discussion about

    systemd switch – https://wiki.debian.org/Debate/initsystem/systemd • The motivation statement why systemd was written – http://0pointer.de/blog/projects/why.html • The source code of systemd – https://github.com/systemd/systemd • Ofcial site – https://freedesktop.org/wiki/Software/systemd/ • An article on systemd and init – http://www.tecmint.com/systemd-replaces-init-in-linux/ • How to debug boot and other things in systemd – https://www.freedesktop.org/wiki/Software/systemd/Debugging/ • Systemd cheat sheet – http://images.linoxide.com/systemd-vs-sysVinit-cheatsheet.pdf
  18. 28 Take home message • systemd is here. Learn it.

    Use it. Be Ninja. • By unifying how the service management is done in your company, the fragmentation can be decreased. • Apart from other benefts, the boarding time can be shorter for new employees and they have less impediments to start bringing value from the frst month. True North. • There are also problem areas. Be aware.
  19. 31