هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
الهدف
Do all tasks on server1 without the summaries — only man, --help and /usr/share/doc. Every result must still work after a reboot. server2 is the NFS server (prepared in "Before you start").
قبل أن تبدأ
- server1 with two extra empty disks
/dev/vdb(5 GiB) and/dev/vdc(5 GiB). server2 at192.168.122.20. - On server2, export home folders over NFS (one time preparation):
dnf install -y nfs-utils mkdir -p /srv/nfs/home/{anna,omar} echo '/srv/nfs/home 192.168.122.0/24(rw,sync)' > /etc/exports.d/home.exports systemctl enable --now nfs-server firewall-cmd --add-service=nfs --permanent ; firewall-cmd --reload
المهام
ضع علامة على المهمة عندما تنتهي منها. متصفحك فقط يتذكر ذلك.
- LVM: make the VG
vg_labfrom/dev/vdbwith an extent size of 8 MiB. Make the LVlv_webwith 100 extents, XFS, mounted on/srv/webat boot. - Grow
lv_webby 200 MiB while it is mounted. Add/dev/vdctovg_lab. - Swap: make the LV
lv_swapof 512 MiB invg_laband use it as swap at boot. - SELinux: Apache must serve the content of
/srv/webon port 82. PutRH134 reviewin/srv/web/index.html. SELinux stays enforcing; open the port in the firewall. - Timer: the script
/usr/local/bin/stamp.sh(writesdateto/var/log/stamp.log) must run every 15 minutes as a systemd timer. - tmpfiles: files older than 2 days in
/var/tmp/cachemust be deleted automatically; the folder must exist after every boot with rights0750. - Journal: keep the journal after reboots, use at most 300 MiB.
- autofs: the folders of server2
/srv/nfs/home/NAMEmust appear as/home/remote/NAMEwhen used. - Tuning and boot: use the recommended tuned profile. The system must boot into
multi-user.target. - Container: user
studentruns a rootless containerwebfromregistry.access.redhat.com/ubi10/httpd-24on port 8080 that starts at boot without a login. - Reboot and check every task.
تحقّق من عملك
vgs vg_lab -o vg_name,vg_extent_size,pv_count
lvs vg_lab
findmnt /srv/web ; swapon --show
curl -s http://server1:82/
getenforce
systemctl list-timers stamp.timer
ls -ld /var/tmp/cache
journalctl --list-boots | tail -n 2
ls /home/remote/anna && findmnt /home/remote/anna
tuned-adm active ; systemctl get-default
sudo -u student XDG_RUNTIME_DIR=/run/user/$(id -u student) systemctl --user is-active web.servicevgsshows the extent size8.00mand 2 PVs;lv_webis 1000 MiB (800 + 200).curlprintsRH134 review, andgetenforceprintsEnforcing.journalctl --list-bootsshows more than one boot.
تلميحات
اعرض التلميحات
- 100 extents × 8 MiB = 800 MiB.
lvextend -rgrows XFS too. semanage fcontext+restoreconfor the folder,semanage port -afor port 82,Listen 82in Apache.- A timer needs a
.serviceand a.timerwith the same name; enable the timer. - tmpfiles line:
d PATH MODE USER GROUP AGE. - autofs:
/home/remote /etc/auto.homeand* -rw,sync server2:/srv/nfs/home/&. - Quadlet file +
loginctl enable-linger student.
الحل
اعرض الحل
- and 2. LVM.
pvcreate /dev/vdb vgcreate -s 8M vg_lab /dev/vdb lvcreate -n lv_web -l 100 vg_lab mkfs.xfs /dev/vg_lab/lv_web mkdir -p /srv/web echo '/dev/vg_lab/lv_web /srv/web xfs defaults 0 0' >> /etc/fstab systemctl daemon-reload ; mount -a lvextend -r -L +200M /dev/vg_lab/lv_web pvcreate /dev/vdc ; vgextend vg_lab /dev/vdc - Swap on LVM.
- Apache on port 82 with SELinux.
dnf install -y httpd echo "RH134 review" > /srv/web/index.html semanage fcontext -a -t httpd_sys_content_t '/srv/web(/.*)?' restorecon -Rv /srv/web sed -i 's/^Listen 80$/Listen 82/' /etc/httpd/conf/httpd.conf sed -i 's#"/var/www/html"#"/srv/web"#g' /etc/httpd/conf/httpd.conf semanage port -a -t http_port_t -p tcp 82 systemctl enable --now httpd firewall-cmd --add-port=82/tcp --permanent ; firewall-cmd --reload - The timer.
printf '#!/bin/bash\ndate >> /var/log/stamp.log\n' > /usr/local/bin/stamp.sh chmod 755 /usr/local/bin/stamp.sh printf '[Unit]\nDescription=Write a time stamp\n[Service]\nType=oneshot\nExecStart=/usr/local/bin/stamp.sh\n' > /etc/systemd/system/stamp.service printf '[Unit]\nDescription=Time stamp every 15 minutes\n[Timer]\nOnCalendar=*:0/15\n[Install]\nWantedBy=timers.target\n' > /etc/systemd/system/stamp.timer systemctl daemon-reload systemctl enable --now stamp.timer - tmpfiles.
echo 'd /var/tmp/cache 0750 root root 2d' > /etc/tmpfiles.d/cache.conf systemd-tmpfiles --create /etc/tmpfiles.d/cache.conf - Persistent journal.
- autofs.
- Tuning and default target.
- The rootless container as student (as root: enable linger first).
loginctl enable-linger student mkdir -p ~/.config/containers/systemd printf '[Container]\nImage=registry.access.redhat.com/ubi10/httpd-24\nContainerName=web\nPublishPort=8080:8080\n[Install]\nWantedBy=default.target\n' > ~/.config/containers/systemd/web.container systemctl --user daemon-reload systemctl --user start web.service - Reboot and run the checks.
systemctl reboot
ملاحظاتي
لا توجد ملاحظات بعد.
دروس هذا المعمل
- 11.3Create logical volumes
- 11.5Grow a logical volume and its file system
- 10.6Add swap space
- 6.4Give files the right type for good
- 14.6Allow a service on a non-standard port
- 4.4Write your own system timer
- 4.6Manage temporary files with systemd-tmpfiles
- 5.4Keep the journal after a reboot
- 15.6Mount every home folder with a wildcard
- 9.2Choose and check a profile
- 12.2Know the targets
- 17.7Start a container at boot with Quadlet