SystemD: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Die Seite wurde neu angelegt: „== Konfiguration == === /etc/systemd/journald.conf === <pre>Storage=persistent SystemMaxFileSize=50M </pre> === systemctl === <pre> </pre> === journalctl ===…“) |
|||
(7 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
[[Kategorie:ServerApplikation]] | |||
== Konfiguration == | == Konfiguration == | ||
=== /etc/systemd/journald.conf === | === /etc/systemd/journald.conf === | ||
Zeile 4: | Zeile 6: | ||
SystemMaxFileSize=50M | SystemMaxFileSize=50M | ||
</pre> | </pre> | ||
* systemctl restart systemd-journald.service | |||
== Kommandos == | |||
=== systemctl === | === systemctl === | ||
<pre> | <pre>systemctl start nginx.service | stop | status | restart | reload | ||
systemctl enable nginx.service | disable | |||
systemctl list-units # laufende Services | |||
systemctl list-unit-files # verfügbare Services | |||
systemctl --failed # missglückte Starts | |||
systemctl mask nginx.service # Als nicht startbar markieren | |||
systemctl unmask nginx.service # mask aufheben | |||
systemctl list-units --type=target | |||
systemctl isolate graphical.target | rescue.target | multi-user.target | |||
systemctl set-default multi-user.target | |||
systemd-analyze | |||
systemd-analyze blame # Startzeiten der Services | |||
</pre> | </pre> | ||
=== journalctl === | === journalctl === | ||
<pre> | <pre>journalctl --since yesterday | --since "2016-03-16 02:00:00" | --since 09:00 --until "1 hour ago" | ||
journalctl --list-boots | |||
journalctl -b -1 # since last boot (relative pointer -1) | |||
journalctl -u nginx.service -u php-fpm.service # by units | |||
journalctl -k # kernel messages | |||
journalctl --no-full # truncated info | |||
journalctl -a # all info | |||
journalctl -n 20 # only the last 20 lines | |||
journalctl -f # like tail -f | |||
journalctl --disk-usage # wie viel braucht das journal | |||
journalctl --vacuum-size=1G # Platz auf 1 GByte reduzieren | |||
</pre> | </pre> | ||
== Beispiel Service | == Beispiel Service Definitionsdatei == | ||
* /lib/systemd/system/redis.service | |||
<pre>[Unit] | <pre>[Unit] | ||
Description=Redis persistent key-value database | Description=Redis persistent key-value database | ||
Zeile 26: | Zeile 57: | ||
[Install] | [Install] | ||
WantedBy=multi-user.target | WantedBy=multi-user.target | ||
</pre> | |||
= Konfiguration = | |||
* Einzelkonfigurationen in /etc/systemd.d | |||
<pre>cat > /etc/sysctl.d/98-no_overcommit.conf <<EOS | |||
# Select memory overcommitment operation mode. | |||
# | |||
# Mode 2 means that no more than | |||
# | |||
# SwapTotal + (MemTotal * vm.overcommit_ratio / 100) | |||
# | |||
# virtual memory can be allocated (Committed_AS) by processes. The resulting | |||
# limit will be displayed as CommitLimit. (All CamelCased values mentioned | |||
# here can be found in "/proc/meminfo".) | |||
# | |||
# Mode 1 means infinite overcommit - every allocation is allowed, no matter | |||
# how much memory is actually available. | |||
# | |||
# Mode 0 is similar but considers the available RAM when granting large | |||
# allocations - as long as only small allocations are made, they are also | |||
# always allowed. | |||
vm.overcommit_memory = 2 | |||
# The conservative default for this is 50 %, meaning that at least half of the | |||
# RAM is left free for buffers and cache (after all swap has been filled up | |||
# already). | |||
# | |||
# Setting it to 98 % in the hope that 2 % free RAM will still be enough for all basic | |||
# system operation besides the page cache (for block buffers and kernel). | |||
vm.overcommit_ratio = 98 | |||
EOS | |||
</pre> | |||
<pre> | |||
sysctl --system | |||
</pre> | </pre> |
Aktuelle Version vom 28. April 2020, 18:52 Uhr
Konfiguration[Bearbeiten]
/etc/systemd/journald.conf[Bearbeiten]
Storage=persistent SystemMaxFileSize=50M
- systemctl restart systemd-journald.service
Kommandos[Bearbeiten]
systemctl[Bearbeiten]
systemctl start nginx.service | stop | status | restart | reload systemctl enable nginx.service | disable systemctl list-units # laufende Services systemctl list-unit-files # verfügbare Services systemctl --failed # missglückte Starts systemctl mask nginx.service # Als nicht startbar markieren systemctl unmask nginx.service # mask aufheben systemctl list-units --type=target systemctl isolate graphical.target | rescue.target | multi-user.target systemctl set-default multi-user.target systemd-analyze systemd-analyze blame # Startzeiten der Services
journalctl[Bearbeiten]
journalctl --since yesterday | --since "2016-03-16 02:00:00" | --since 09:00 --until "1 hour ago" journalctl --list-boots journalctl -b -1 # since last boot (relative pointer -1) journalctl -u nginx.service -u php-fpm.service # by units journalctl -k # kernel messages journalctl --no-full # truncated info journalctl -a # all info journalctl -n 20 # only the last 20 lines journalctl -f # like tail -f journalctl --disk-usage # wie viel braucht das journal journalctl --vacuum-size=1G # Platz auf 1 GByte reduzieren
Beispiel Service Definitionsdatei[Bearbeiten]
- /lib/systemd/system/redis.service
[Unit] Description=Redis persistent key-value database After=network.target [Service] ExecStart=/usr/local/bin/redis-server ExecStop=/usr/local/bin/redis-shutdown WorkingDirectory=/var/lib/redis User=redis Group=redis [Install] WantedBy=multi-user.target
Konfiguration[Bearbeiten]
- Einzelkonfigurationen in /etc/systemd.d
cat > /etc/sysctl.d/98-no_overcommit.conf <<EOS # Select memory overcommitment operation mode. # # Mode 2 means that no more than # # SwapTotal + (MemTotal * vm.overcommit_ratio / 100) # # virtual memory can be allocated (Committed_AS) by processes. The resulting # limit will be displayed as CommitLimit. (All CamelCased values mentioned # here can be found in "/proc/meminfo".) # # Mode 1 means infinite overcommit - every allocation is allowed, no matter # how much memory is actually available. # # Mode 0 is similar but considers the available RAM when granting large # allocations - as long as only small allocations are made, they are also # always allowed. vm.overcommit_memory = 2 # The conservative default for this is 50 %, meaning that at least half of the # RAM is left free for buffers and cache (after all swap has been filled up # already). # # Setting it to 98 % in the hope that 2 % free RAM will still be enough for all basic # system operation besides the page cache (for block buffers and kernel). vm.overcommit_ratio = 98 EOS
sysctl --system