Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

Lab 11.1RHCSA 10, Hoofdstuk 11

Manage and change services

Niveau
Gemiddeld
30 min
Machines
server1
Status
Nog niet begonnen

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Doel

Install a web server, make it start at boot, make it restart by itself after a crash, block a service, and add a small service of your own.

Voordat je begint

  • Work on server1 as root. A repository must be available (lab 9.1).

Taken

  1. Install httpd. Start it now and make sure it also starts at boot.
  2. Show if httpd is active and enabled, with two short commands.
  3. Change httpd (without editing the file from the package) so that it is always restarted 5 seconds after it stops for any reason.
  4. Kill the main httpd process with SIGKILL and show that systemd starts it again.
  5. Make sure that the service nftables can never be started by accident, then try to start it.
  6. Create the service hello that writes "hello" and the date to the journal every minute. It must start at boot.

Controleer je werk

systemctl is-active httpd; systemctl is-enabled httpd
systemctl cat httpd | tail -4
systemctl status httpd | grep 'Main PID'
systemctl is-enabled nftables
journalctl -u hello --since -5min
  • httpd: active and enabled; the override shows Restart=always and RestartSec=5.
  • After the kill, the Main PID is new.
  • nftables: masked.
  • hello: lines with "hello" in the journal; systemctl is-enabled hello = enabled.

Hints

Toon de hints

Oplossing

Toon de oplossing
  1. Install and enable.
    dnf install -y httpd
    systemctl enable --now httpd
  2. Short checks.
    systemctl is-active httpd; systemctl is-enabled httpd
  3. The override: add these lines in the editor.
    systemctl edit httpd
    /etc/systemd/system/httpd.service.d/override.conf
    [Service]
    Restart=always
    RestartSec=5
  4. Kill and watch it come back.
    systemctl kill -s KILL --kill-whom=main httpd
    sleep 6; systemctl status httpd | grep -E 'Active|Main PID'
  5. Mask nftables.
    systemctl mask --now nftables
    systemctl start nftables
    Failed to start nftables.service: Unit nftables.service is masked.
  6. The hello service.
    /etc/systemd/system/hello.service
    [Unit]
    Description=Hello demo service
     
    [Service]
    ExecStart=/usr/bin/bash -c 'while true; do echo "hello $(date)"; sleep 60; done'
    Restart=on-failure
     
    [Install]
    WantedBy=multi-user.target
    systemctl daemon-reload
    systemctl enable --now hello

Mijn notities

Nog geen notities.

Lessen voor dit lab

Commando's in dit lab