8
This commit is contained in:
286
8.html
286
8.html
@@ -120,6 +120,7 @@
|
||||
<td style="padding:4px 8px;line-height:118%;">Reboot. Alle Netzverbindungen werden geschlossen, Dateipuffer werden geschrieben, Mounts auf Partitionen werden entfernt.
|
||||
</td></tr></tbody></table>
|
||||
</section>
|
||||
|
||||
|
||||
<section data-transition="slide" data-background="#4d7e65" data-background-transition="convex">
|
||||
<h2>Part 5 - systemd</h2>
|
||||
@@ -139,6 +140,12 @@
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h4>Der Boot-Ablauf mit systemd</h4>
|
||||
<img style="max-height: 50vh" src="img/startup-systemd.png">
|
||||
<p><small> Das initramfs ist ein komprimiertes Archiv, das für den Systemstart benötigte Dateien enthält.</small>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
|
||||
<p>systemd ist organisiert mit
|
||||
<ul>
|
||||
@@ -161,100 +168,14 @@
|
||||
<li class="fragment ">Systemstatus anzeigen:<pre><code>systemctl status</code></pre></li>
|
||||
<li class="fragment ">Liste der fehlgeschlagenene Units <pre><code>systemctl --failed</code></pre></li>
|
||||
<li class="fragment ">Liste aller installierter Units<pre><code>systemctl list-unit-files</code></pre></li>
|
||||
</ul>
|
||||
</section>
|
||||
<section>
|
||||
|
||||
<section>
|
||||
<h3>Dienste Steuern</h3>
|
||||
<ul>
|
||||
<li class="fragment ">Laufende Dienste anzeigen:<pre><code>systemctl</code></pre></li>
|
||||
<li class="fragment ">Eine Unit starten <pre><code>systemctl start DIENST</code></pre></li>
|
||||
<li class="fragment ">Eine Unit neu starten<pre><code>systemctl restart DIENST</code></pre></li>
|
||||
<li class="fragment ">Unit Status anzeigen<pre><code>systemctl status DIENST</code></pre></li>
|
||||
</ul>
|
||||
<div>Default Target<pre><code>systemctl get-default</code></pre></div>
|
||||
<div class="fragment ">Alle Targets<pre><code>systemctl list-units --type target</code></pre></div >
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<ul>
|
||||
<li class="fragment ">Dienst Autostart anschalten<pre><code>systemctl enable DIENST</code></pre></li>
|
||||
<li class="fragment ">Dienst Autostart anschalten und sofort starten<pre><code>systemctl enable --now DIENST</code></pre></li>
|
||||
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h3>Eine unit</h3>
|
||||
<pre style="font-size: .4em"><code>[Unit]
|
||||
Description=OpenBSD Secure Shell server
|
||||
After=network.target auditd.service
|
||||
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=-/etc/default/ssh
|
||||
ExecStartPre=/usr/sbin/sshd -t
|
||||
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
|
||||
ExecReload=/usr/sbin/sshd -t
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
RestartPreventExitStatus=255
|
||||
Type=notify
|
||||
RuntimeDirectory=sshd
|
||||
RuntimeDirectoryMode=0755
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Alias=sshd.service
|
||||
</code></pre>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<span style="color: orange">Aufgabe:</span> Erstellt eine Unit und startet sie.
|
||||
<div class="fragment">
|
||||
<code style="font-size: .5em">/etc/systemd/system/simple-webserver.service</code>
|
||||
<pre><code>[Unit]
|
||||
Description=Simple Web Server
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/home/USERNAME-HIER-EINSETZEN/hello-web.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
</code></pre>
|
||||
<code style="font-size: .5em">~/hello-web.sh</code>
|
||||
<pre><code>#!/bin/bash
|
||||
cd /home/
|
||||
python3 -m http.server 8082 </code></pre>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<pre><code>systemctl start simple-webserver.service</code></pre>
|
||||
<pre><code>systemctl status simple-webserver.service</code></pre>
|
||||
Wenn das gescheitert sein sollte:
|
||||
<pre><code>journalctl -xe </code></pre>
|
||||
<pre><code>journalctl --unit=simple-webserver.service </code></pre>
|
||||
</section>
|
||||
|
||||
<section>Browser öffnen: <code>http://localhost:8082/BENUTZERNAME</code></section>
|
||||
|
||||
<section><h4>Ändern der Standard-Units</h4>
|
||||
|
||||
<ul>
|
||||
<li class="fragment "> <pre><code>systemctl edit unit</code></pre></li>
|
||||
<li class="fragment "> Öffnet <code>/etc/systemd/system/unit.d/override.conf</code></li>
|
||||
<li class="fragment ">UnDo: <pre><code>systemctl revert unit</code></pre></li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h4>Ensprechenungen der alten Runlevel und der neuen Targets</h4>
|
||||
|
||||
<table class="wikitable" style="font-size:.4em">
|
||||
@@ -301,44 +222,181 @@ python3 -m http.server 8082 </code></pre>
|
||||
</tbody></table>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
Ausserdem:
|
||||
<section>
|
||||
<h3>Dienste Steuern</h3>
|
||||
<ul>
|
||||
<li class="fragment ">Laufende Dienste anzeigen:<pre><code>systemctl</code></pre></li>
|
||||
<li class="fragment ">Eine Unit starten <pre><code>systemctl start DIENST</code></pre></li>
|
||||
<li class="fragment ">Eine Unit neu starten<pre><code>systemctl restart DIENST</code></pre></li>
|
||||
<li class="fragment ">Unit Status anzeigen<pre><code>systemctl status DIENST</code></pre></li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<ul>
|
||||
<li class="fragment ">Dienst Autostart anschalten<pre><code>systemctl enable DIENST</code></pre></li>
|
||||
<li class="fragment ">Dienst Autostart anschalten und sofort starten<pre><code>systemctl enable --now DIENST</code></pre></li>
|
||||
<li class="fragment ">Dienst Autostart abschalten<pre><code>systemctl disable DIENST</code></pre></li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h3>Eine unit</h3>
|
||||
<code style="font-size: .4em">/lib/systemd/system/ssh.service</code>
|
||||
<pre style="font-size: .4em"><code>[Unit]
|
||||
Description=OpenBSD Secure Shell server
|
||||
After=network.target auditd.service
|
||||
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=-/etc/default/ssh
|
||||
ExecStartPre=/usr/sbin/sshd -t
|
||||
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
|
||||
ExecReload=/usr/sbin/sshd -t
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
RestartPreventExitStatus=255
|
||||
Type=notify
|
||||
RuntimeDirectory=sshd
|
||||
RuntimeDirectoryMode=0755
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Alias=sshd.service
|
||||
</code></pre>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<span style="color: orange">Aufgabe:</span> Erstellt eine Unit und startet sie.<p>
|
||||
https://wiki.archlinux.org/index.php/Systemd#Writing_unit_files
|
||||
<div class="fragment">
|
||||
<code style="font-size: .5em">/etc/systemd/system/simple-webserver.service</code>
|
||||
<pre><code>[Unit]
|
||||
Description=Simple Web Server
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/home/USERNAME-HIER-EINSETZEN/hello-web.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
</code></pre>
|
||||
<code style="font-size: .5em">~/hello-web.sh</code>
|
||||
<pre><code>#!/bin/bash
|
||||
cd /home/
|
||||
python3 -m http.server 8082 </code></pre>
|
||||
</div>
|
||||
|
||||
<ul>
|
||||
<li class="fragment ">mount -> systemd kann Dateisysteme mounten</li>
|
||||
<li class="fragment ">timer -> systemd kann cron ersetzen</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h4>journalctl</h4>
|
||||
Das logging system moderner Linux Distributionen.
|
||||
</section>
|
||||
<section>
|
||||
<pre><code>systemctl start simple-webserver.service</code></pre>
|
||||
<pre><code>systemctl status simple-webserver.service</code></pre>
|
||||
Wenn das gescheitert sein sollte:
|
||||
<pre><code>journalctl -xe </code></pre>
|
||||
<pre><code>journalctl --unit=simple-webserver.service </code></pre>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h4>systemctl</h4>
|
||||
</section>
|
||||
<section>Browser öffnen: <code>http://localhost:8082/BENUTZERNAME</code></section>
|
||||
|
||||
<section><h4>Ändern der Standard-Units</h4>
|
||||
|
||||
<section data-transition="slide" data-background="#4d7e65" data-background-transition="convex">
|
||||
<h2>Part 5 - daemons</h2>
|
||||
<ul>
|
||||
<li class="fragment "> <pre><code>systemctl edit unit</code></pre></li>
|
||||
<li class="fragment "> Öffnet <code>/etc/systemd/system/unit.d/override.conf</code></li>
|
||||
<li class="fragment "> Aktualiseren <code>systemctl daemon-reload </code></li>
|
||||
<li class="fragment ">UnDo: <pre><code>systemctl revert unit</code></pre></li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
timer als cron Ersatz
|
||||
<pre><code>systemctl list-timers --all</code></pre>
|
||||
<div class="fragment">die Timer Datei muss den selben namen haben wie das Unit-File<p><code>toller-dienst.service</code><p><code>toller-dienst.timer</code></div>
|
||||
|
||||
<aside class="notes">
|
||||
timer datei ansehen
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
https://wiki.archlinux.org/index.php/Systemd/Timers
|
||||
<aside class="notes">üben doku lesen</aside>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<span style="color: orange">Aufgabe:</span> Erstellt einen Backup Service, der per systemd Timer einmal wöchentlich läuft.
|
||||
|
||||
<div class="fragment">
|
||||
<code style="font-size: .5em">/etc/systemd/system/backup.timer</code>
|
||||
<pre><code>
|
||||
[Unit]
|
||||
Description=Run backup.sh weekly
|
||||
|
||||
[Timer]
|
||||
OnCalendar=weekly
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
</code></pre>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section data-transition="slide" data-background="#4d7e65" data-background-transition="convex">
|
||||
<h2>Part 6 - Uhrzeit und Datum</h2>
|
||||
</section>
|
||||
|
||||
<section data-transition="slide" data-background="#4d7e65" data-background-transition="convex">
|
||||
<h2>Part 7 - Startup / Shutdown</h2>
|
||||
|
||||
<section>
|
||||
<h4>Der Boot-Ablauf mit systemd</h4>
|
||||
<img style="max-height: 50vh" src="img/startup-systemd.png">
|
||||
<p><small> Das initramfs ist ein komprimiertes Archiv, das für den Systemstart benötigte Dateien enthält.</small>
|
||||
<code style="font-size: .5em">/etc/systemd/system/backup.service</code>
|
||||
<pre><code>
|
||||
[Unit]
|
||||
Description=Backup 2000
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/home/USERNAME-HIER-EINSETZEN/bin/backup.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
</code></pre>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<code style="font-size: .5em">~/bin/backup.sh</code>
|
||||
<pre style="font-size: .4em"><code>#!/bin/bash
|
||||
tar -czf "/home/USERNAME/archiv/backup-`date +%d-%m-%Y`.tar.gz" /home/USERNAME/arbeit/
|
||||
</code></pre>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h4>journalctl</h4>
|
||||
<pre><code>journalctl</code></pre>
|
||||
<pre><code>journalctl -xe</code></pre>
|
||||
<pre><code>journalctl --unit=backup.service </code></pre>
|
||||
|
||||
<aside class="notes">man journalctl</aside>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
timedatectl
|
||||
<p>https://wiki.ubuntuusers.de/Systemzeit/
|
||||
|
||||
<p>https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-managing_services_with_systemd-targets
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
<section data-transition="slide" data-background="#4d7e65" data-background-transition="convex">
|
||||
<h2>Part 7 - Startup / Shutdown</h2>
|
||||
</section>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Reference in New Issue
Block a user