От sysV к systemd

Preview:

Citation preview

От sysV к systemd

Ковалев Денис

Уютный SysVinit● кто не писал /etc/init.d/....

скрипты?● unix way● cron● системные логи

Стоит ли переходить?

This is the Unix philosophy

1. Write programs that do one thing and do it well.

2. Write programs to work together.3. Write programs to handle text

streams, because that is a universal interface.

Doug McIlroy

Сколько нужно команд, чтобы узнать OS?

$ uname -a

$ cat /etc/issue

$ cat /etc/*release$ cat /etc/*version

$ lsb_release -a

hostnamectl$ hostnamectl Static hostname: static.216.201.250.124.clients.de Icon name: computer-vm Chassis: vm Machine ID: 426df1cf0ef241c8bac0ae65ebd450b2 Boot ID: 421a1f60665c4d2284cfb0e6ba190e17 Virtualization: kvm Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-327.18.2.el7.x86_64 Architecture: x86-64

Сколько нужно команд, чтобы вкрутить лампочку?

$ /etc/init.d/lightbulb$ chkconfig lightbulb on$ /etc/supervisord.d/lightbulb.conf+ logging+ cron

systemctl$ /usr/lib/systemd/system/lightbulb.service$ systemctl enable lightbulb

sshd[Unit]Description=OpenSSH server daemonDocumentation=man:sshd(8) man:sshd_config(5)After=network.target sshd-keygen.serviceWants=sshd-keygen.service

sshd[Service]EnvironmentFile=/etc/sysconfig/sshdExecStart=/usr/sbin/sshd -D $OPTIONSExecReload=/bin/kill -HUP $MAINPIDKillMode=processRestart=on-failureRestartSec=42s

sshd

[Install]WantedBy=multi-user.target

date$ dateThu Jun 30 06:59:40 UTC 2016

$ timedatectl Local time: Thu 2016-06-30 06:59:40 UTC Universal time: Thu 2016-06-30 06:59:40 UTC RTC time: Thu 2016-06-30 06:59:40 Time zone: UTC (UTC, +0000) NTP enabled: yesNTP synchronized: yes RTC in local TZ: no DST active: n/a

2011 2012 2013 2014 2015

systemctl● start● stop● reload● restart● try-restart● reload-or-restart● reload-or-try-restart● kill● is-active● is-failed● status● show● cat● help

● enable● disable● reenable● is-enabled● mask● unmask● edit● snapshot● list-jobs● cancel● show-environment● set-environment● is-system-running

● list-dependencies● rescue● halt● poweroff● reboot

systemctl status$ systemctl status sshd● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2016-06-09 14:50:43 UTC; 2 weeks 6 days ago Docs: man:sshd(8) man:sshd_config(5) Main PID: 889 (sshd) CGroup: /system.slice/sshd.service └─889 /usr/sbin/sshd -D

Binary logs$ journalctl -ex -u sshd | tailJun 15 05:09:50 example.com sshd[28300]: Connection closed by 84.227.235.191 [preauth]Jun 15 05:10:28 example.com sshd[28387]: Connection closed by 90.103.213.98 [preauth]Jun 15 05:14:18 example.com sshd[28704]: Received disconnect from 115.31.116.38: 11: [preauth]Jun 15 05:14:52 example.com sshd[28762]: Connection closed by 90.103.213.98 [preauth]Jun 15 05:17:58 example.com sshd[29055]: Received disconnect from 125.18.238.11: 11: [preauth]Jun 15 05:19:12 example.com sshd[29144]: Connection closed by 90.103.213.98 [preauth]Jun 15 05:23:34 example.com sshd[29559]: Connection closed by 90.103.213.98 [preauth]Jun 15 05:23:46 example.com sshd[29564]: Received disconnect from 115.19.218.29: 11: [preauth]Jun 15 05:26:36 example.com sshd[29827]: Received disconnect from 111.31.119.26: 11: [preauth]Jun 15 05:27:57 example.com sshd[29934]: Connection closed by 90.103.213.98 [preauth]

Analyze boot time$ systemd-analyzeStartup finished in 569ms (kernel) + 770ms (initrd) + 9.244s (userspace) = 10.584s$ systemd-analyze critical-chainmulti-user.target @9.239s└─tuned.service @6.201s +263ms └─network.target @6.200s └─network.service @5.678s +520ms └─NetworkManager.service @794ms +51ms └─basic.target @793ms...

и не только...● параллелизация● cлежение за запущеными сервисами (systemd-cgls,

systemd-cgtop)● взаимодействие с udev● D-Bus API● systemd-escape & systemd-path● Запуск произвольной программы под systemd

(systemd-run)● Настройка локалей (localectl)● ....

Спасибо за внимание

Ковалев Денис

skype: aikikodeemail: aikikode@gmail.com

Recommended