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
Vink een taak aan als hij klaar is. Alleen je browser onthoudt dit.
- Install
httpd. Start it now and make sure it also starts at boot. - Show if httpd is active and enabled, with two short commands.
- Change httpd (without editing the file from the package) so that it is always restarted 5 seconds after it stops for any reason.
- Kill the main httpd process with SIGKILL and show that systemd starts it again.
- Make sure that the service
nftablescan never be started by accident, then try to start it. - Create the service
hellothat 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:
activeandenabled; the override showsRestart=alwaysandRestartSec=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
systemctl enable --now.systemctl edit httpdwrites a drop-in file.systemctl kill -s KILL httpdorkill -9on the Main PID.systemctl mask.- A unit file in
/etc/systemd/system/with[Install] WantedBy=multi-user.target.
Oplossing
Toon de oplossing
- Install and enable.
- Short checks.
- The override: add these lines in the editor.
systemctl edit httpd/etc/systemd/system/httpd.service.d/override.conf[Service] Restart=always RestartSec=5 - Kill and watch it come back.
- Mask nftables.
- 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
Mijn notities
Nog geen notities.