Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
elearning:workbooks:redhat:rh124:l111 [2024/09/26 11:49] – removed admin | elearning:workbooks:redhat:rh124:l111 [2024/09/26 13:19] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ~~PDF: | ||
+ | Version : **2024.01** | ||
+ | |||
+ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
+ | |||
+ | ======RH12412 - Gestion des Services et des Démons====== | ||
+ | |||
+ | =====Contenu du Module===== | ||
+ | |||
+ | * **RH12412 - Gestion des Services et des Démons** | ||
+ | * Contenu du Module | ||
+ | * Systemd | ||
+ | * LAB #1 - La Commande systemctl | ||
+ | * LAB #2 - Fichiers de Configuration | ||
+ | * 2.1 - Fichiers de Configuration par Défaut | ||
+ | * 2.2 - Surchargement des Fichiers de Configuration par Défaut | ||
+ | * LAB #3 - La Commande systemd-analyze | ||
+ | * LAB #4 - Les Cibles Systemd | ||
+ | * 4.1 - Contrôler les dépendances d'une Cible | ||
+ | * 4.2 - La Cible par Défaut | ||
+ | * LAB #5 - Gestion des Services | ||
+ | * 5.1 - Gestion des Instances Uniques | ||
+ | * 5.2 - Gestion d' | ||
+ | * 5.3 - Interdire la Modification du Statut d'un Service | ||
+ | |||
+ | =====Systemd===== | ||
+ | |||
+ | Les systèmes de démarrage antérieurs à Systemd, **SysVinit** et **Upstart**, | ||
+ | |||
+ | **Systemd** essaie, par contre, de démarrer autant de services en parallèle que possible. Ceci est rendu possible car la majorité d' | ||
+ | |||
+ | Au lieu de parler de scripts de démarrage et de niveaux d' | ||
+ | |||
+ | * **.automount** - active la fonctionalité d' | ||
+ | * **.device** - expose une périphérique dans systemd. | ||
+ | * **.mount** - contrôle quand et comment les systèmes de fichiers sont montés. | ||
+ | * **.path** - active un service quand il y a un accès à un fichier ou répertoire sous surveillance par le système. | ||
+ | * **.service** - démarre, arrête, redémarre ou recharge un service. | ||
+ | * **.scope** - gère des services. | ||
+ | * **.slice** - regroupe des Unités dans une arborescence afin de limiter des ressources en utilisant des CGroups. | ||
+ | * **.snapshot** - un état sauvegardé du gestionnaire Systemd. | ||
+ | * **.socket** - permet aux Unités d' | ||
+ | * **.swap** - encapsule une périphérique ou un fichier swap. | ||
+ | * **.timer** - déclenche l' | ||
+ | * **.target** - regroupe des Unités multiples afin qu' | ||
+ | |||
+ | Une Cible est en quelque sorte une **grande étape** dans le démarrage du système : | ||
+ | |||
+ | * **halt.target** - arrête le système. | ||
+ | * **poweroff.target** - arrête le système et coupe le courant. | ||
+ | * **shutdown.target** - arrête le système. | ||
+ | * **rescue.target** - démarre le système en mode single-user (seul root peut s'y connecter). Tous les systèmes de fichiers sont montés mais le réseau n'est pas démarré. | ||
+ | * **emergency.target** - démarre le système en mode single-user (seul root peut s'y connecter). Uniquement le système de fichiers racine est monté en mode lecture seule. Le réseau n'est pas démarré. | ||
+ | * **multi-user.target** - démarre le système en mode multi-utilisateur avec tous les systèmes de fichiers montés et le service network démarré. | ||
+ | * **graphical.target** - démarre le système en multi-user.target puis démarre l' | ||
+ | * **hibernate.target** - sauvegarde l' | ||
+ | * **reboot.target** - redémarre le système. | ||
+ | |||
+ | **Systemd** utilise des Cibles d'une manière similaire à ce que **SysVinit** utilise des niveaux d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 15 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 13 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 17 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 17 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 17 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 16 Jul 18 13:00 / | ||
+ | lrwxrwxrwx. 1 root root 13 Jul 18 13:00 / | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | </ | ||
+ | |||
+ | ====LAB #1 - La Commande systemctl==== | ||
+ | |||
+ | Pour visualiser la liste des Unités, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl list-units | ||
+ | UNIT | ||
+ | proc-sys-fs-binfmt_misc.automount | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-platform-serial8250-tty-ttyS0.device | ||
+ | sys-devices-platform-serial8250-tty-ttyS1.device | ||
+ | sys-devices-platform-serial8250-tty-ttyS2.device | ||
+ | sys-devices-platform-serial8250-tty-ttyS3.device | ||
+ | sys-devices-virtual-block-dm\x2d0.device | ||
+ | sys-devices-virtual-block-dm\x2d1.device | ||
+ | sys-devices-virtual-misc-rfkill.device | ||
+ | sys-module-configfs.device | ||
+ | sys-module-fuse.device | ||
+ | sys-subsystem-net-devices-ens18.device | ||
+ | -.mount | ||
+ | boot.mount | ||
+ | dev-hugepages.mount | ||
+ | dev-mqueue.mount | ||
+ | proc-sys-fs-binfmt_misc.mount | ||
+ | run-credentials-systemd\x2dsysctl.service.mount | ||
+ | run-credentials-systemd\x2dtmpfiles\x2dsetup.service.mount | ||
+ | run-credentials-systemd\x2dtmpfiles\x2dsetup\x2ddev.service.mount | ||
+ | run-user-1000.mount | ||
+ | run-user-42.mount | ||
+ | sys-fs-fuse-connections.mount | ||
+ | sys-kernel-config.mount | ||
+ | sys-kernel-debug-tracing.mount | ||
+ | sys-kernel-debug.mount | ||
+ | sys-kernel-tracing.mount | ||
+ | cups.path | ||
+ | systemd-ask-password-plymouth.path | ||
+ | systemd-ask-password-wall.path | ||
+ | init.scope | ||
+ | session-4.scope | ||
+ | lines 1-37...skipping... | ||
+ | UNIT | ||
+ | proc-sys-fs-binfmt_misc.automount | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-platform-serial8250-tty-ttyS0.device | ||
+ | sys-devices-platform-serial8250-tty-ttyS1.device | ||
+ | sys-devices-platform-serial8250-tty-ttyS2.device | ||
+ | sys-devices-platform-serial8250-tty-ttyS3.device | ||
+ | sys-devices-virtual-block-dm\x2d0.device | ||
+ | sys-devices-virtual-block-dm\x2d1.device | ||
+ | sys-devices-virtual-misc-rfkill.device | ||
+ | sys-module-configfs.device | ||
+ | sys-module-fuse.device | ||
+ | sys-subsystem-net-devices-ens18.device | ||
+ | -.mount | ||
+ | boot.mount | ||
+ | dev-hugepages.mount | ||
+ | dev-mqueue.mount | ||
+ | proc-sys-fs-binfmt_misc.mount | ||
+ | run-credentials-systemd\x2dsysctl.service.mount | ||
+ | run-credentials-systemd\x2dtmpfiles\x2dsetup.service.mount | ||
+ | run-credentials-systemd\x2dtmpfiles\x2dsetup\x2ddev.service.mount | ||
+ | run-user-1000.mount | ||
+ | run-user-42.mount | ||
+ | sys-fs-fuse-connections.mount | ||
+ | sys-kernel-config.mount | ||
+ | sys-kernel-debug-tracing.mount | ||
+ | sys-kernel-debug.mount | ||
+ | sys-kernel-tracing.mount | ||
+ | cups.path | ||
+ | systemd-ask-password-plymouth.path | ||
+ | systemd-ask-password-wall.path | ||
+ | init.scope | ||
+ | session-4.scope | ||
+ | session-c1.scope | ||
+ | accounts-daemon.service | ||
+ | atd.service | ||
+ | auditd.service | ||
+ | avahi-daemon.service | ||
+ | colord.service | ||
+ | crond.service | ||
+ | cups.service | ||
+ | dbus-broker.service | ||
+ | dracut-shutdown.service | ||
+ | firewalld.service | ||
+ | gdm.service | ||
+ | irqbalance.service | ||
+ | iscsi.service | ||
+ | kdump.service | ||
+ | kmod-static-nodes.service | ||
+ | libstoragemgmt.service | ||
+ | lvm2-monitor.service | ||
+ | lines 1-55 | ||
+ | </ | ||
+ | |||
+ | Pour consulter la liste des Unités inactifs, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl list-units --all | grep inactive | more | ||
+ | ● boot.automount | ||
+ | ● home.mount | ||
+ | ● sysroot.mount | ||
+ | tmp.mount | ||
+ | ● var.mount | ||
+ | systemd-ask-password-console.path | ||
+ | alsa-restore.service | ||
+ | alsa-state.service | ||
+ | ● auto-cpufreq.service | ||
+ | ● autofs.service | ||
+ | blk-availability.service | ||
+ | cpupower.service | ||
+ | dm-event.service | ||
+ | dnf-makecache.service | ||
+ | dracut-cmdline.service | ||
+ | dracut-initqueue.service | ||
+ | dracut-mount.service | ||
+ | dracut-pre-mount.service | ||
+ | dracut-pre-pivot.service | ||
+ | dracut-pre-trigger.service | ||
+ | dracut-pre-udev.service | ||
+ | dracut-shutdown-onfailure.service | ||
+ | ● ebtables.service | ||
+ | emergency.service | ||
+ | ● fcoe.service | ||
+ | getty@tty1.service | ||
+ | initrd-cleanup.service | ||
+ | initrd-parse-etc.service | ||
+ | initrd-switch-root.service | ||
+ | initrd-udevadm-cleanup-db.service | ||
+ | insights-client-boot.service | ||
+ | ● ip6tables.service | ||
+ | ● ipset.service | ||
+ | ● iptables.service | ||
+ | iscsi-init.service | ||
+ | iscsi-onboot.service | ||
+ | iscsi-shutdown.service | ||
+ | iscsi-starter.service | ||
+ | iscsid.service | ||
+ | iscsiuio.service | ||
+ | ldconfig.service | ||
+ | logrotate.service | ||
+ | low-memory-monitor.service | ||
+ | ● lvm2-activation-early.service | ||
+ | lvm2-lvmpolld.service | ||
+ | mdmonitor.service | ||
+ | microcode.service | ||
+ | mlocate-updatedb.service | ||
+ | modprobe@configfs.service | ||
+ | modprobe@drm.service | ||
+ | modprobe@fuse.service | ||
+ | multipathd.service | ||
+ | ● network.service | ||
+ | nftables.service | ||
+ | ● nslcd.service | ||
+ | --More-- | ||
+ | [q] | ||
+ | </ | ||
+ | |||
+ | Les points noirs au début de certaines lignes dans la sortie ci-dessus sont en réalité des points blancs à l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl status network | ||
+ | Unit network.service could not be found. | ||
+ | </ | ||
+ | |||
+ | Pour consulter la liste des Unités ainsi que leurs statuts, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl list-unit-files | more | ||
+ | UNIT FILE STATE | ||
+ | proc-sys-fs-binfmt_misc.automount | ||
+ | -.mount | ||
+ | boot.mount | ||
+ | dev-hugepages.mount | ||
+ | dev-mqueue.mount | ||
+ | proc-sys-fs-binfmt_misc.mount | ||
+ | run-vmblock\x2dfuse.mount | ||
+ | sys-fs-fuse-connections.mount | ||
+ | sys-kernel-config.mount | ||
+ | sys-kernel-debug.mount | ||
+ | sys-kernel-tracing.mount | ||
+ | tmp.mount | ||
+ | cups.path | ||
+ | insights-client-results.path | ||
+ | ostree-finalize-staged.path | ||
+ | systemd-ask-password-console.path | ||
+ | systemd-ask-password-plymouth.path | ||
+ | systemd-ask-password-wall.path | ||
+ | session-4.scope | ||
+ | session-c1.scope | ||
+ | accounts-daemon.service | ||
+ | alsa-restore.service | ||
+ | alsa-state.service | ||
+ | arp-ethers.service | ||
+ | atd.service | ||
+ | auditd.service | ||
+ | autovt@.service | ||
+ | avahi-daemon.service | ||
+ | blk-availability.service | ||
+ | bluetooth.service | ||
+ | bolt.service | ||
+ | brltty.service | ||
+ | canberra-system-bootup.service | ||
+ | canberra-system-shutdown-reboot.service | ||
+ | canberra-system-shutdown.service | ||
+ | chrony-wait.service | ||
+ | chronyd-restricted.service | ||
+ | chronyd.service | ||
+ | cni-dhcp.service | ||
+ | cockpit-motd.service | ||
+ | cockpit-wsinstance-http.service | ||
+ | cockpit-wsinstance-https-factory@.service | ||
+ | cockpit-wsinstance-https@.service | ||
+ | cockpit.service | ||
+ | colord.service | ||
+ | configure-printer@.service | ||
+ | console-getty.service | ||
+ | container-getty@.service | ||
+ | cpupower.service | ||
+ | crond.service | ||
+ | cups-browsed.service | ||
+ | cups.service | ||
+ | dbus-broker.service | ||
+ | dbus-daemon.service | ||
+ | --More-- | ||
+ | [q] | ||
+ | </ | ||
+ | |||
+ | Pour visualiser les Unités d'un type spécifique, | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl list-unit-files -t mount | ||
+ | UNIT FILE | ||
+ | -.mount | ||
+ | boot.mount | ||
+ | dev-hugepages.mount | ||
+ | dev-mqueue.mount | ||
+ | proc-sys-fs-binfmt_misc.mount disabled | ||
+ | run-vmblock\x2dfuse.mount | ||
+ | sys-fs-fuse-connections.mount static | ||
+ | sys-kernel-config.mount | ||
+ | sys-kernel-debug.mount | ||
+ | sys-kernel-tracing.mount | ||
+ | tmp.mount | ||
+ | |||
+ | 11 unit files listed. | ||
+ | </ | ||
+ | |||
+ | Dans la colonne STATE on voit les mots **static** et **generated**. | ||
+ | |||
+ | * STATE = static | ||
+ | * Ceci implique que l' | ||
+ | |||
+ | * STATE = generated | ||
+ | * Ceci implique que le fichier a été généré automatiquement en utilisant les informations dans le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# ls -l / | ||
+ | -rwxr-xr-x. 1 root root 57696 Jul 18 13:01 / | ||
+ | </ | ||
+ | |||
+ | Il existe aussi d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# ls -l / | ||
+ | total 396 | ||
+ | -rwxr-xr-x. 1 root root 541 Jul 24 06:08 kdump-dep-generator.sh | ||
+ | -rwxr-xr-x. 1 root root 15832 May 17 18:27 ostree-system-generator | ||
+ | lrwxrwxrwx. 1 root root 31 Aug 8 10:54 podman-system-generator -> ../ | ||
+ | -rwxr-xr-x. 1 root root 1005 Feb 19 2024 selinux-autorelabel-generator.sh | ||
+ | -rwxr-xr-x. 1 root root 15624 Jul 18 13:01 systemd-bless-boot-generator | ||
+ | -rwxr-xr-x. 1 root root 40920 Jul 18 13:01 systemd-cryptsetup-generator | ||
+ | -rwxr-xr-x. 1 root root 24312 Jul 18 13:01 systemd-debug-generator | ||
+ | -rwxr-xr-x. 1 root root 57696 Jul 18 13:01 systemd-fstab-generator | ||
+ | -rwxr-xr-x. 1 root root 24096 Jul 18 13:01 systemd-getty-generator | ||
+ | -rwxr-xr-x. 1 root root 36496 Jul 18 13:01 systemd-gpt-auto-generator | ||
+ | -rwxr-xr-x. 1 root root 16096 Jul 18 13:01 systemd-hibernate-resume-generator | ||
+ | -rwxr-xr-x. 1 root root 24240 Jul 18 13:01 systemd-integritysetup-generator | ||
+ | -rwxr-xr-x. 1 root root 15632 Jul 18 13:01 systemd-rc-local-generator | ||
+ | -rwxr-xr-x. 1 root root 24296 Jul 18 13:01 systemd-run-generator | ||
+ | -rwxr-xr-x. 1 root root 15824 Jul 18 13:01 systemd-system-update-generator | ||
+ | -rwxr-xr-x. 1 root root 36424 Jul 18 13:01 systemd-sysv-generator | ||
+ | -rwxr-xr-x. 1 root root 36872 Jul 18 13:01 systemd-veritysetup-generator | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **systemctl** sont : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl --help | ||
+ | systemctl [OPTIONS...] COMMAND ... | ||
+ | |||
+ | Query or send control commands to the system manager. | ||
+ | |||
+ | Unit Commands: | ||
+ | list-units [PATTERN...] | ||
+ | list-automounts [PATTERN...] | ||
+ | ordered by path | ||
+ | list-sockets [PATTERN...] | ||
+ | ordered by address | ||
+ | list-timers [PATTERN...] | ||
+ | ordered by next elapse | ||
+ | is-active PATTERN... | ||
+ | is-failed PATTERN... | ||
+ | status [PATTERN...|PID...] | ||
+ | show [PATTERN...|JOB...] | ||
+ | units/jobs or the manager | ||
+ | cat PATTERN... | ||
+ | help PATTERN...|PID... | ||
+ | list-dependencies [UNIT...] | ||
+ | or wanted by the units or by which those | ||
+ | units are required or wanted | ||
+ | start UNIT... | ||
+ | stop UNIT... | ||
+ | reload UNIT... | ||
+ | restart UNIT... | ||
+ | try-restart UNIT... | ||
+ | reload-or-restart UNIT... | ||
+ | otherwise start or restart | ||
+ | try-reload-or-restart UNIT... | ||
+ | if supported, otherwise restart | ||
+ | isolate UNIT Start one unit and stop all others | ||
+ | kill UNIT... | ||
+ | clean UNIT... | ||
+ | configuration of unit | ||
+ | freeze PATTERN... | ||
+ | thaw PATTERN... | ||
+ | set-property UNIT PROPERTY=VALUE... Sets one or more properties of a unit | ||
+ | bind UNIT PATH [PATH] | ||
+ | unit's namespace | ||
+ | mount-image UNIT PATH [PATH [OPTS]] Mount an image from the host into a | ||
+ | unit's namespace | ||
+ | service-log-level SERVICE [LEVEL] | ||
+ | service-log-target SERVICE [TARGET] Get/set logging target for service | ||
+ | reset-failed [PATTERN...] | ||
+ | units | ||
+ | Unit File Commands: | ||
+ | list-unit-files [PATTERN...] | ||
+ | enable [UNIT...|PATH...] | ||
+ | disable UNIT... | ||
+ | reenable UNIT... | ||
+ | preset UNIT... | ||
+ | based on preset configuration | ||
+ | preset-all | ||
+ | preset configuration | ||
+ | lines 1-55 | ||
+ | </ | ||
+ | |||
+ | ====LAB #2 - Fichiers de Configuration==== | ||
+ | |||
+ | ===2.1 - Fichiers de Configuration par Défaut=== | ||
+ | |||
+ | Les fichiers de configuration des Cibles et fichiers de configuration des Unités installés par des paquets se trouvent dans le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# pkg-config systemd --variable=systemdsystemunitdir | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# ls -l / | ||
+ | total 1584 | ||
+ | -rw-r--r--. 1 root root 729 Feb 24 2022 accounts-daemon.service | ||
+ | -rw-r--r--. 1 root root 480 Jan 16 2024 alsa-restore.service | ||
+ | -rw-r--r--. 1 root root 465 Jan 16 2024 alsa-state.service | ||
+ | -rw-r--r--. 1 root root 275 Aug 10 2021 arp-ethers.service | ||
+ | -rw-r--r--. 1 root root 274 Apr 4 2022 atd.service | ||
+ | -rw-r--r--. 1 root root 1771 Nov 8 2023 auditd.service | ||
+ | lrwxrwxrwx. 1 root root 14 Jul 18 13:00 autovt@.service -> getty@.service | ||
+ | -rw-r--r--. 1 root root 1044 Nov 8 2023 avahi-daemon.service | ||
+ | -rw-r--r--. 1 root root 870 Nov 8 2023 avahi-daemon.socket | ||
+ | -rw-r--r--. 1 root root 964 Jul 18 13:00 basic.target | ||
+ | drwxr-xr-x. 2 root root 6 Jul 18 13:00 basic.target.wants | ||
+ | -r--r--r--. 1 root root 384 Feb 3 2024 blk-availability.service | ||
+ | -rw-r--r--. 1 root root 449 Oct 31 2022 blockdev@.target | ||
+ | -rw-r--r--. 1 root root 707 Jun 14 2022 bluetooth.service | ||
+ | -rw-r--r--. 1 root root 435 Oct 31 2022 bluetooth.target | ||
+ | -rw-r--r--. 1 root root 642 Jan 16 2023 bolt.service | ||
+ | -rw-r--r--. 1 root root 463 Oct 31 2022 boot-complete.target | ||
+ | -rw-r--r--. 1 root root 217 Aug 9 2021 brltty.service | ||
+ | -rw-r--r--. 1 root root 491 Jul 13 2023 canberra-system-bootup.service | ||
+ | -rw-r--r--. 1 root root 509 Jul 13 2023 canberra-system-shutdown-reboot.service | ||
+ | -rw-r--r--. 1 root root 466 Jul 13 2023 canberra-system-shutdown.service | ||
+ | -rw-r--r--. 1 root root 1811 Jan 23 2024 chronyd-restricted.service | ||
+ | -rw-r--r--. 1 root root 1468 Jan 23 2024 chronyd.service | ||
+ | -rw-r--r--. 1 root root 1082 Jan 23 2024 chrony-wait.service | ||
+ | -rw-r--r--. 1 root root 277 Jul 23 09:37 cni-dhcp.service | ||
+ | -rw-r--r--. 1 root root 302 Dec 4 2023 cni-dhcp.socket | ||
+ | -rw-r--r--. 1 root root 222 Apr 2 05:45 cockpit-motd.service | ||
+ | -rw-r--r--. 1 root root 720 Apr 2 05:45 cockpit.service | ||
+ | -rw-r--r--. 1 root root 349 Apr 2 05:45 cockpit.socket | ||
+ | -rw-r--r--. 1 root root 221 Apr 2 05:45 cockpit-wsinstance-http.service | ||
+ | -rw-r--r--. 1 root root 165 Apr 2 05:45 cockpit-wsinstance-https-factory@.service | ||
+ | -rw-r--r--. 1 root root 244 Apr 2 05:45 cockpit-wsinstance-https-factory.socket | ||
+ | -rw-r--r--. 1 root root 215 Apr 2 05:45 cockpit-wsinstance-http.socket | ||
+ | -rw-r--r--. 1 root root 264 Apr 2 05:45 cockpit-wsinstance-https@.service | ||
+ | -rw-r--r--. 1 root root 478 Apr 2 05:45 cockpit-wsinstance-https@.socket | ||
+ | -rw-r--r--. 1 root root 295 Aug 9 2021 colord.service | ||
+ | -rw-r--r--. 1 root root 154 Aug 11 2021 configure-printer@.service | ||
+ | -rw-r--r--. 1 root root 1102 Jul 18 13:00 console-getty.service | ||
+ | -rw-r--r--. 1 root root 1254 Jul 18 13:00 container-getty@.service | ||
+ | -rw-r--r--. 1 root root 294 Sep 13 18:49 cpupower.service | ||
+ | -rw-r--r--. 1 root root 371 Nov 30 2023 crond.service | ||
+ | -rw-r--r--. 1 root root 473 Oct 31 2022 cryptsetup-pre.target | ||
+ | -rw-r--r--. 1 root root 420 Oct 31 2022 cryptsetup.target | ||
+ | lrwxrwxrwx. 1 root root 13 Jul 18 13:00 ctrl-alt-del.target -> reboot.target | ||
+ | -rw-r--r--. 1 root root 234 Jan 7 2021 cups-browsed.service | ||
+ | -rw-r--r--. 1 root root 142 Jun 19 11:00 cups.path | ||
+ | -rw-r--r--. 1 root root 298 Jun 19 11:00 cups.service | ||
+ | drwxr-xr-x. 2 root root 25 Sep 25 12:03 cups.service.d | ||
+ | -rw-r--r--. 1 root root 148 Jun 19 11:00 cups.socket | ||
+ | -rw-r--r--. 1 root root 529 Aug 23 2022 dbus-broker.service | ||
+ | -rw-r--r--. 1 root root 560 Jun 12 2023 dbus-daemon.service | ||
+ | lrwxrwxrwx. 1 root root 25 Jul 18 13:00 dbus-org.freedesktop.hostname1.service -> systemd-hostnamed.service | ||
+ | lrwxrwxrwx. 1 root root 23 Jul 18 13:00 dbus-org.freedesktop.locale1.service -> systemd-localed.service | ||
+ | lrwxrwxrwx. 1 root root 22 Jul 18 13:00 dbus-org.freedesktop.login1.service -> systemd-logind.service | ||
+ | --More-- | ||
+ | [q] | ||
+ | </ | ||
+ | |||
+ | Certains fichiers de configuration sont créés à la volée dans le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# ls -l / | ||
+ | total 0 | ||
+ | </ | ||
+ | |||
+ | Les fichiers de configuration des Unités crées par les utilisateurs doivent être mis dans le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# pkg-config systemd --variable=systemduserunitdir | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : De cette façon les fichiers dans **/ | ||
+ | </ | ||
+ | |||
+ | Prenons le cas du service **sshd** qui est configuré par le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# cat / | ||
+ | [Unit] | ||
+ | Description=OpenSSH server daemon | ||
+ | Documentation=man: | ||
+ | After=network.target sshd-keygen.target | ||
+ | Wants=sshd-keygen.target | ||
+ | |||
+ | [Service] | ||
+ | Type=notify | ||
+ | EnvironmentFile=-/ | ||
+ | ExecStart=/ | ||
+ | ExecReload=/ | ||
+ | KillMode=process | ||
+ | Restart=on-failure | ||
+ | RestartSec=42s | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | </ | ||
+ | |||
+ | Dans le fichier on peut noter la présence des lignes suivantes dans la section **[Unit]** : | ||
+ | |||
+ | * **Description=OpenSSH server daemon**, | ||
+ | * Cette directive est utilisée pour donner une courte description des fonctionnalités de l' | ||
+ | * **Documentation=man: | ||
+ | * Cette directive stipule les chapitres des manuels et les URLs contenant de l' | ||
+ | * **After=network.target sshd-keygen.target**, | ||
+ | * Cette directive indique les cibles qui devraient être atteintes et les Unités qui devraient être démarrées avant l' | ||
+ | * **Wants=sshd-keygen.target**, | ||
+ | * Cette directive stipule une dépendance douce. Autrement dit, Systemd essayera de démarrer l' | ||
+ | |||
+ | Dans le fichier on peut aussi noter la présence des lignes suivantes dans la section **[Service]** : | ||
+ | |||
+ | * **Type=notify**, | ||
+ | * Cette directive indique que le service informera Systemd quand son démarrage a terminé, | ||
+ | * **ExecStart=/ | ||
+ | * Cette directive définit l' | ||
+ | * **ExecReload=/ | ||
+ | * Cette directive indique la commande necéssaire pour redémarrer le service, | ||
+ | * **KillMode=process**, | ||
+ | * Cette directive indique comment les processus du service doivent être arrêtés. La valeur de **process** implique l' | ||
+ | * **Restart=on-failure**, | ||
+ | * Cette ligne indique que le service doit être re-démarré en cas d' | ||
+ | * **RestartSec=42s**, | ||
+ | * Cette directive stipule le temps d' | ||
+ | |||
+ | Dernièrement on note la présence de la ligne suivante dans la section **[Install]** : | ||
+ | |||
+ | * **WantedBy=multi-user.target**, | ||
+ | * Cette directive indique la Cible dans laquelle le service doit être démarré. La présence de cette directive crée un lien symbolique dans le répertoire **/ | ||
+ | |||
+ | Pour consulter **l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl show sshd | ||
+ | Type=notify | ||
+ | ExitType=main | ||
+ | Restart=on-failure | ||
+ | NotifyAccess=main | ||
+ | RestartUSec=42s | ||
+ | TimeoutStartUSec=1min 30s | ||
+ | TimeoutStopUSec=1min 30s | ||
+ | TimeoutAbortUSec=1min 30s | ||
+ | TimeoutStartFailureMode=terminate | ||
+ | TimeoutStopFailureMode=terminate | ||
+ | RuntimeMaxUSec=infinity | ||
+ | RuntimeRandomizedExtraUSec=0 | ||
+ | WatchdogUSec=0 | ||
+ | WatchdogTimestampMonotonic=0 | ||
+ | RootDirectoryStartOnly=no | ||
+ | RemainAfterExit=no | ||
+ | GuessMainPID=yes | ||
+ | MainPID=875 | ||
+ | ControlPID=0 | ||
+ | FileDescriptorStoreMax=0 | ||
+ | NFileDescriptorStore=0 | ||
+ | StatusErrno=0 | ||
+ | Result=success | ||
+ | ReloadResult=success | ||
+ | CleanResult=success | ||
+ | UID=[not set] | ||
+ | GID=[not set] | ||
+ | NRestarts=0 | ||
+ | OOMPolicy=stop | ||
+ | ReloadSignal=1 | ||
+ | ExecMainStartTimestamp=Wed 2024-09-25 12:44:53 CEST | ||
+ | ExecMainStartTimestampMonotonic=18089127 | ||
+ | ExecMainExitTimestampMonotonic=0 | ||
+ | ExecMainPID=875 | ||
+ | ExecMainCode=0 | ||
+ | ExecMainStatus=0 | ||
+ | ExecStart={ path=/ | ||
+ | ExecStartEx={ path=/ | ||
+ | ExecReload={ path=/ | ||
+ | ExecReloadEx={ path=/ | ||
+ | Slice=system.slice | ||
+ | ControlGroup=/ | ||
+ | ControlGroupId=3690 | ||
+ | MemoryCurrent=5275648 | ||
+ | MemoryAvailable=infinity | ||
+ | CPUUsageNSec=122370000 | ||
+ | TasksCurrent=1 | ||
+ | IPIngressBytes=[no data] | ||
+ | IPIngressPackets=[no data] | ||
+ | IPEgressBytes=[no data] | ||
+ | IPEgressPackets=[no data] | ||
+ | IOReadBytes=18446744073709551615 | ||
+ | IOReadOperations=18446744073709551615 | ||
+ | IOWriteBytes=18446744073709551615 | ||
+ | IOWriteOperations=18446744073709551615 | ||
+ | lines 1-55 | ||
+ | </ | ||
+ | |||
+ | Pour consulter la liste des dépendances d'une Unité, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl list-dependencies sshd.service | ||
+ | sshd.service | ||
+ | ● ├─system.slice | ||
+ | ● ├─sshd-keygen.target | ||
+ | ○ │ ├─sshd-keygen@ecdsa.service | ||
+ | ○ │ ├─sshd-keygen@ed25519.service | ||
+ | ○ │ └─sshd-keygen@rsa.service | ||
+ | ● └─sysinit.target | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ○ | ||
+ | ○ | ||
+ | ● | ||
+ | ○ | ||
+ | ● | ||
+ | ● | ||
+ | ○ | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ○ | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ○ | ||
+ | ○ | ||
+ | ○ | ||
+ | ● | ||
+ | ○ | ||
+ | ○ | ||
+ | ○ | ||
+ | ● | ||
+ | ● | ||
+ | ○ | ||
+ | ● | ||
+ | ● | ||
+ | ○ | ||
+ | ○ | ||
+ | ○ | ||
+ | ● | ||
+ | ○ | ||
+ | ● | ||
+ | ○ | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ○ | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● │ ├─-.mount | ||
+ | lines 1-55 | ||
+ | </ | ||
+ | |||
+ | ===2.2 - Surchargement des Fichiers de Configuration par Défaut=== | ||
+ | |||
+ | Les fichiers de configuration par défaut peuvent aussi être surchargés par des fichiers dans d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# pkg-config systemd --variable=systemdsystemunitpath | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# ls -l / | ||
+ | total 8 | ||
+ | drwxr-xr-x. 2 root root 65 Oct 19 2023 basic.target.wants | ||
+ | drwxr-xr-x. 2 root root 31 Oct 19 2023 bluetooth.target.wants | ||
+ | lrwxrwxrwx. 1 root root 37 Oct 19 2023 ctrl-alt-del.target -> / | ||
+ | lrwxrwxrwx. 1 root root 41 Oct 19 2023 dbus-org.bluez.service -> / | ||
+ | lrwxrwxrwx. 1 root root 41 Oct 19 2023 dbus-org.fedoraproject.FirewallD1.service -> / | ||
+ | lrwxrwxrwx. 1 root root 44 Oct 19 2023 dbus-org.freedesktop.Avahi.service -> / | ||
+ | lrwxrwxrwx. 1 root root 44 Oct 19 2023 dbus-org.freedesktop.ModemManager1.service -> / | ||
+ | lrwxrwxrwx. 1 root root 57 Oct 19 2023 dbus-org.freedesktop.nm-dispatcher.service -> / | ||
+ | lrwxrwxrwx. 1 root root 43 Oct 19 2023 dbus.service -> / | ||
+ | lrwxrwxrwx. 1 root root 40 Oct 19 2023 default.target -> / | ||
+ | drwxr-xr-x. 2 root root 45 Oct 19 2023 default.target.wants | ||
+ | drwxr-xr-x. 2 root root 38 Oct 19 2023 ' | ||
+ | lrwxrwxrwx. 1 root root 35 Oct 19 2023 display-manager.service -> / | ||
+ | drwxr-xr-x. 2 root root 32 Oct 19 2023 getty.target.wants | ||
+ | drwxr-xr-x. 2 root root 181 Oct 19 2023 graphical.target.wants | ||
+ | drwxr-xr-x. 2 root root 36 Oct 19 2023 local-fs.target.wants | ||
+ | drwxr-xr-x. 2 root root 4096 Oct 19 2023 multi-user.target.wants | ||
+ | drwxr-xr-x. 2 root root 48 Oct 19 2023 network-online.target.wants | ||
+ | drwxr-xr-x. 2 root root 26 Oct 19 2023 printer.target.wants | ||
+ | drwxr-xr-x. 2 root root 27 Oct 19 2023 remote-fs.target.wants | ||
+ | drwxr-xr-x. 2 root root 186 Oct 19 2023 sockets.target.wants | ||
+ | drwxr-xr-x. 2 root root 4096 Sep 25 12:08 sysinit.target.wants | ||
+ | drwxr-xr-x. 2 root root 86 Oct 19 2023 timers.target.wants | ||
+ | drwxr-xr-x. 2 root root 29 Oct 19 2023 vmtoolsd.service.requires | ||
+ | </ | ||
+ | |||
+ | ====LAB #3 - La Commande systemd-analyze==== | ||
+ | |||
+ | Pour avoir une évaluation du temps de démarrage, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemd-analyze | ||
+ | Startup finished in 1.309s (kernel) + 4.384s (initrd) + 29.375s (userspace) = 35.069s | ||
+ | graphical.target reached after 29.358s in userspace. | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemd-analyze blame | ||
+ | 15.289s plymouth-quit-wait.service | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | 953ms ModemManager.service | ||
+ | 900ms user@42.service | ||
+ | 888ms dracut-initqueue.service | ||
+ | 671ms dbus-broker.service | ||
+ | 661ms systemd-tmpfiles-setup-dev.service | ||
+ | 658ms systemd-udevd.service | ||
+ | 561ms lvm2-monitor.service | ||
+ | 547ms boot.mount | ||
+ | 506ms cups.service | ||
+ | 464ms sshd.service | ||
+ | 446ms logrotate.service | ||
+ | 382ms systemd-random-seed.service | ||
+ | 376ms auditd.service | ||
+ | 371ms systemd-tmpfiles-setup.service | ||
+ | 324ms systemd-sysctl.service | ||
+ | lines 1-55 | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemd-analyze critical-chain sshd.service | ||
+ | The time when unit became active or started is printed after the " | ||
+ | The time the unit took to start is printed after the " | ||
+ | |||
+ | sshd.service +464ms | ||
+ | └─network.target @12.377s | ||
+ | └─wpa_supplicant.service @25.556s +119ms | ||
+ | └─basic.target @7.432s | ||
+ | └─dbus-broker.service @6.758s +671ms | ||
+ | └─dbus.socket @6.741s | ||
+ | └─sysinit.target @6.737s | ||
+ | └─systemd-update-utmp.service @6.721s +15ms | ||
+ | └─auditd.service @6.333s +376ms | ||
+ | └─systemd-tmpfiles-setup.service @5.951s +371ms | ||
+ | └─local-fs.target @5.939s | ||
+ | └─run-user-42.mount @14.616s | ||
+ | └─local-fs-pre.target @5.379s | ||
+ | └─systemd-tmpfiles-setup-dev.service @3.398s +661ms | ||
+ | └─kmod-static-nodes.service @3.243s +49ms | ||
+ | └─systemd-journald.socket | ||
+ | └─system.slice | ||
+ | └─-.slice | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **systemd-analyze** sont : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemd-analyze --help | ||
+ | systemd-analyze [OPTIONS...] COMMAND ... | ||
+ | |||
+ | Profile systemd, show unit dependencies, | ||
+ | |||
+ | Commands: | ||
+ | [time] | ||
+ | blame Print list of running units ordered by | ||
+ | time to init | ||
+ | critical-chain [UNIT...] | ||
+ | of units | ||
+ | plot | ||
+ | | ||
+ | dot [UNIT...] | ||
+ | dump [PATTERN...] | ||
+ | | ||
+ | cat-config | ||
+ | unit-files | ||
+ | unit-paths | ||
+ | exit-status [STATUS...] | ||
+ | capability [CAP...] | ||
+ | syscall-filter [NAME...] | ||
+ | filesystems [NAME...] | ||
+ | condition CONDITION... | ||
+ | compare-versions VERSION1 [OP] VERSION2 | ||
+ | | ||
+ | verify FILE... | ||
+ | calendar SPEC... | ||
+ | | ||
+ | timestamp TIMESTAMP... | ||
+ | timespan SPAN... | ||
+ | security [UNIT...] | ||
+ | inspect-elf FILE... | ||
+ | |||
+ | Options: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | of built-in one | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | with either --table or --json= | ||
+ | | ||
+ | | ||
+ | | ||
+ | -H --host=[USER@]HOST | ||
+ | -M --machine=CONTAINER | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | lines 1-55 | ||
+ | </ | ||
+ | |||
+ | ====LAB #4 - Les Cibles Systemd==== | ||
+ | |||
+ | Chaque Cible est décrite par un fichier de configuration : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# cat / | ||
+ | # SPDX-License-Identifier: | ||
+ | # | ||
+ | # This file is part of systemd. | ||
+ | # | ||
+ | # systemd is free software; you can redistribute it and/or modify it | ||
+ | # under the terms of the GNU Lesser General Public License as published by | ||
+ | # the Free Software Foundation; either version 2.1 of the License, or | ||
+ | # (at your option) any later version. | ||
+ | |||
+ | [Unit] | ||
+ | Description=Graphical Interface | ||
+ | Documentation=man: | ||
+ | Requires=multi-user.target | ||
+ | Wants=display-manager.service | ||
+ | Conflicts=rescue.service rescue.target | ||
+ | After=multi-user.target rescue.service rescue.target display-manager.service | ||
+ | AllowIsolate=yes | ||
+ | </ | ||
+ | |||
+ | Dans ce fichier on peut noter la présence des lignes suivantes : | ||
+ | |||
+ | * **Requires=multi-user.target**, | ||
+ | * Cette ligne indique que le **graphical.target** ne peut pas être atteint si le **multi-user.target** n'a pas été atteint au préalable, | ||
+ | * **After=multi-user.target rescue.service rescue.target display-manager.service**, | ||
+ | * Cette ligne indique le **multi-user.target** et **rescue.target** doivent d' | ||
+ | * **Conflicts=rescue.service rescue.target**, | ||
+ | * Cette ligne indique la Cible et le service en conflits avec le **graphical.target**, | ||
+ | * **Wants=display-manager.service**, | ||
+ | * Cette ligne indique quel service doit être démarré. | ||
+ | |||
+ | ===4.1 - Contrôler les dépendances d'une Cible=== | ||
+ | |||
+ | Les dépendances d'une Cible peuvent être consultées en utilisant la commande **systemctl list-dependencies** : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl list-dependencies multi-user.target | ||
+ | multi-user.target | ||
+ | ● ├─atd.service | ||
+ | ● ├─auditd.service | ||
+ | ● ├─avahi-daemon.service | ||
+ | ● ├─crond.service | ||
+ | ● ├─cups.path | ||
+ | ● ├─cups.service | ||
+ | ● ├─firewalld.service | ||
+ | ○ ├─insights-client-boot.service | ||
+ | ● ├─irqbalance.service | ||
+ | ● ├─kdump.service | ||
+ | ● ├─libstoragemgmt.service | ||
+ | ● ├─mcelog.service | ||
+ | ○ ├─mdmonitor.service | ||
+ | ● ├─ModemManager.service | ||
+ | ● ├─NetworkManager.service | ||
+ | ○ ├─ostree-readonly-sysroot-migration.service | ||
+ | ● ├─plymouth-quit-wait.service | ||
+ | ○ ├─plymouth-quit.service | ||
+ | ● ├─rhsmcertd.service | ||
+ | ● ├─rsyslog.service | ||
+ | ○ ├─smartd.service | ||
+ | ● ├─sshd.service | ||
+ | ○ ├─sssd.service | ||
+ | ● ├─systemd-ask-password-wall.path | ||
+ | ● ├─systemd-logind.service | ||
+ | ○ ├─systemd-update-utmp-runlevel.service | ||
+ | ● ├─systemd-user-sessions.service | ||
+ | ○ ├─tuned.service | ||
+ | ○ ├─vmtoolsd.service | ||
+ | ● ├─basic.target | ||
+ | ● │ ├─-.mount | ||
+ | ○ │ ├─low-memory-monitor.service | ||
+ | ○ │ ├─microcode.service | ||
+ | ● │ ├─paths.target | ||
+ | ● │ ├─slices.target | ||
+ | ● │ │ ├─-.slice | ||
+ | ● │ │ └─system.slice | ||
+ | ● │ ├─sockets.target | ||
+ | ● │ │ ├─avahi-daemon.socket | ||
+ | ● │ │ ├─cups.socket | ||
+ | ● │ │ ├─dbus.socket | ||
+ | ● │ │ ├─dm-event.socket | ||
+ | ● │ │ ├─iscsid.socket | ||
+ | ● │ │ ├─iscsiuio.socket | ||
+ | ○ │ │ ├─multipathd.socket | ||
+ | ● │ │ ├─sssd-kcm.socket | ||
+ | ● │ │ ├─systemd-coredump.socket | ||
+ | ● │ │ ├─systemd-initctl.socket | ||
+ | ● │ │ ├─systemd-journald-dev-log.socket | ||
+ | ● │ │ ├─systemd-journald.socket | ||
+ | ● │ │ ├─systemd-udevd-control.socket | ||
+ | ● │ │ └─systemd-udevd-kernel.socket | ||
+ | ● │ ├─sysinit.target | ||
+ | ● │ │ ├─dev-hugepages.mount | ||
+ | lines 1-55 | ||
+ | </ | ||
+ | |||
+ | Les points noirs au début de chaque ligne dans la sortie ci-dessus peuvent être de trois couleurs différentes : | ||
+ | |||
+ | * **Vert** implique que le service, la cible ou l' | ||
+ | * **Blanc** implique le service, la cible ou l' | ||
+ | * **Rouge** implique que le service, la cible ou l' | ||
+ | |||
+ | Pour visualiser les Unités en état d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl --failed | ||
+ | UNIT LOAD ACTIVE SUB DESCRIPTION | ||
+ | 0 loaded units listed. | ||
+ | </ | ||
+ | |||
+ | Les dépendances sont créés sous la forme de liens symboliques dans les répertoires **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# ls -l / | ||
+ | total 0 | ||
+ | lrwxrwxrwx. 1 root root 35 Oct 19 2023 atd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 38 Oct 19 2023 auditd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 44 Oct 19 2023 avahi-daemon.service -> / | ||
+ | lrwxrwxrwx. 1 root root 37 Oct 19 2023 crond.service -> / | ||
+ | lrwxrwxrwx. 1 root root 33 Oct 19 2023 cups.path -> / | ||
+ | lrwxrwxrwx. 1 root root 36 Oct 19 2023 cups.service -> / | ||
+ | lrwxrwxrwx. 1 root root 41 Oct 19 2023 firewalld.service -> / | ||
+ | lrwxrwxrwx. 1 root root 52 Oct 19 2023 insights-client-boot.service -> / | ||
+ | lrwxrwxrwx. 1 root root 42 Oct 19 2023 irqbalance.service -> / | ||
+ | lrwxrwxrwx. 1 root root 37 Oct 19 2023 kdump.service -> / | ||
+ | lrwxrwxrwx. 1 root root 46 Oct 19 2023 libstoragemgmt.service -> / | ||
+ | lrwxrwxrwx. 1 root root 38 Oct 19 2023 mcelog.service -> / | ||
+ | lrwxrwxrwx. 1 root root 41 Oct 19 2023 mdmonitor.service -> / | ||
+ | lrwxrwxrwx. 1 root root 44 Oct 19 2023 ModemManager.service -> / | ||
+ | lrwxrwxrwx. 1 root root 46 Oct 19 2023 NetworkManager.service -> / | ||
+ | lrwxrwxrwx. 1 root root 40 Oct 19 2023 remote-fs.target -> / | ||
+ | lrwxrwxrwx. 1 root root 41 Oct 19 2023 rhsmcertd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 39 Oct 19 2023 rsyslog.service -> / | ||
+ | lrwxrwxrwx. 1 root root 38 Oct 19 2023 smartd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 36 Oct 19 2023 sshd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 36 Oct 19 2023 sssd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 37 Oct 19 2023 tuned.service -> / | ||
+ | lrwxrwxrwx. 1 root root 40 Oct 19 2023 vmtoolsd.service -> / | ||
+ | |||
+ | [root@redhat9 ~]# ls -l / | ||
+ | total 0 | ||
+ | lrwxrwxrwx. 1 root root 15 Jul 18 13:00 getty.target -> ../ | ||
+ | lrwxrwxrwx. 1 root root 44 May 17 18:27 ostree-readonly-sysroot-migration.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 24 Jul 14 2023 plymouth-quit.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 29 Jul 14 2023 plymouth-quit-wait.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 33 Jul 18 13:00 systemd-ask-password-wall.path -> ../ | ||
+ | lrwxrwxrwx. 1 root root 25 Jul 18 13:00 systemd-logind.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 39 Jul 18 13:00 systemd-update-utmp-runlevel.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 32 Jul 18 13:00 systemd-user-sessions.service -> ../ | ||
+ | </ | ||
+ | |||
+ | ===4.2 - La Cible par Défaut=== | ||
+ | |||
+ | ==Consulter la Cible par Défaut== | ||
+ | |||
+ | Pour consulter la cible par défaut, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl get-default | ||
+ | graphical.target | ||
+ | </ | ||
+ | |||
+ | La Cible par défaut est représentée par le lien symbolique **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 40 Oct 19 2023 / | ||
+ | </ | ||
+ | |||
+ | ==Modifier la Cible par Défaut== | ||
+ | |||
+ | Pour modifier la Cible par défaut avec une prise en compte lors du **prochain** démarrage, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl set-default multi-user.target | ||
+ | Removed "/ | ||
+ | Created symlink / | ||
+ | |||
+ | [root@redhat9 ~]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 41 Sep 26 14:50 / | ||
+ | |||
+ | [root@redhat9 ~]# systemctl set-default graphical.target | ||
+ | Removed "/ | ||
+ | Created symlink / | ||
+ | |||
+ | [root@redhat9 ~]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 40 Sep 26 14:51 / | ||
+ | </ | ||
+ | |||
+ | ==Modifier la Cible en Cours== | ||
+ | |||
+ | Il est possible de modifier la cible actuellement en cours en utilisant la commande **systemctl isolate** : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl isolate rescue | ||
+ | |||
+ | [root@redhat9 ~]# systemctl list-units --type target | egrep " | ||
+ | rescue.target | ||
+ | | ||
+ | [root@redhat9 ~]# runlevel | ||
+ | 5 1 | ||
+ | |||
+ | [root@redhat9 ~]# who -r | ||
+ | | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl isolate graphical | ||
+ | |||
+ | [root@redhat9 ~]# systemctl list-units --type target | egrep " | ||
+ | graphical.target | ||
+ | |||
+ | [root@redhat9 ~]# runlevel | ||
+ | 1 5 | ||
+ | |||
+ | [root@redhat9 ~]# who -r | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ====LAB #5 - Gestion des Services==== | ||
+ | |||
+ | ===5.1 - Gestion des Instances Uniques=== | ||
+ | |||
+ | Commencez par installer le paquet **httpd** : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# dnf install httpd | ||
+ | Updating Subscription Management repositories. | ||
+ | Last metadata expiration check: 1:59:56 ago on Thu 26 Sep 2024 12:57:02 PM CEST. | ||
+ | Dependencies resolved. | ||
+ | ================================================================================================================================================================================================================== | ||
+ | | ||
+ | ================================================================================================================================================================================================================== | ||
+ | Installing: | ||
+ | | ||
+ | Installing dependencies: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | Installing weak dependencies: | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Transaction Summary | ||
+ | ================================================================================================================================================================================================================== | ||
+ | Install | ||
+ | |||
+ | Total download size: 2.2 M | ||
+ | Installed size: 6.0 M | ||
+ | Is this ok [y/N]: y | ||
+ | Downloading Packages: | ||
+ | (1/11): apr-util-bdb-1.6.1-23.el9.x86_64.rpm | ||
+ | (2/11): apr-util-openssl-1.6.1-23.el9.x86_64.rpm | ||
+ | (3/11): apr-util-1.6.1-23.el9.x86_64.rpm | ||
+ | (4/11): redhat-logos-httpd-90.4-2.el9.noarch.rpm | ||
+ | (5/11): apr-1.7.0-12.el9_3.x86_64.rpm | ||
+ | (6/11): mod_http2-2.0.26-2.el9_4.x86_64.rpm | ||
+ | (7/11): httpd-core-2.4.57-11.el9_4.1.x86_64.rpm | ||
+ | (8/11): httpd-filesystem-2.4.57-11.el9_4.1.noarch.rpm | ||
+ | (9/11): httpd-2.4.57-11.el9_4.1.x86_64.rpm | ||
+ | (10/11): httpd-tools-2.4.57-11.el9_4.1.x86_64.rpm | ||
+ | (11/11): mod_lua-2.4.57-11.el9_4.1.x86_64.rpm | ||
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ||
+ | Total 1.2 MB/s | 2.2 MB | ||
+ | Running transaction check | ||
+ | Transaction check succeeded. | ||
+ | Running transaction test | ||
+ | Transaction test succeeded. | ||
+ | Running transaction | ||
+ | Preparing | ||
+ | Installing | ||
+ | Installing | ||
+ | Installing | ||
+ | Installing | ||
+ | Installing | ||
+ | Running scriptlet: httpd-filesystem-2.4.57-11.el9_4.1.noarch | ||
+ | Installing | ||
+ | Installing | ||
+ | Installing | ||
+ | Installing | ||
+ | Installing | ||
+ | Installing | ||
+ | Running scriptlet: httpd-2.4.57-11.el9_4.1.x86_64 | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Installed products updated. | ||
+ | |||
+ | Installed: | ||
+ | apr-1.7.0-12.el9_3.x86_64 | ||
+ | httpd-core-2.4.57-11.el9_4.1.x86_64 | ||
+ | redhat-logos-httpd-90.4-2.el9.noarch | ||
+ | |||
+ | Complete! | ||
+ | </ | ||
+ | |||
+ | Pour obtenir le détail sur un service donné, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl status httpd.service | ||
+ | ○ httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | </ | ||
+ | |||
+ | Dans le cas du service httpd ci-dessus, on peut constater que le statut est **disabled**. Le statut peut être une de 2 valeurs : | ||
+ | |||
+ | * **disabled** - le service ne démarrera pas lors du prochain démarrage du système. | ||
+ | * **enabled** - le service démarrera lors du prochain démarrage du système. | ||
+ | |||
+ | Il est possible de vérifier le statut en utilisant le commande **systemctl is-enabled** : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl is-enabled httpd.service | ||
+ | disabled | ||
+ | </ | ||
+ | |||
+ | Pour rendre le statut **enabled**, | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl enable httpd.service | ||
+ | Created symlink / | ||
+ | |||
+ | [root@redhat9 ~]# systemctl is-enabled httpd.service | ||
+ | enabled | ||
+ | |||
+ | [root@redhat9 ~]# systemctl status httpd.service | ||
+ | ○ httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | </ | ||
+ | |||
+ | Dans le cas du service httpd ci-dessus, on peut maintenant constater que l' | ||
+ | |||
+ | * **inactive (dead)** - le service est arrêté. | ||
+ | * **active(running** - le service est démarré avec un ou plusieurs processus. | ||
+ | * **active(exited)** - le service a terminé une configuration unique. | ||
+ | * **active(waiting)** - le service est démarré mais en attente d'un évènement. | ||
+ | * **activating** - le service est en cours d' | ||
+ | * **deactivating** - le service est en cours de désactivation. | ||
+ | * **failed** - le service a rencontré une erreur fatale. | ||
+ | |||
+ | Il est possible de vérifier l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl is-active httpd.service | ||
+ | inactive | ||
+ | </ | ||
+ | |||
+ | Pour rendre l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl start httpd.service | ||
+ | </ | ||
+ | |||
+ | Vérifiez ensuite l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl is-active httpd.service | ||
+ | active | ||
+ | |||
+ | [root@redhat9 ~]# systemctl status httpd.service | ||
+ | ● httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | Main PID: 7187 (httpd) | ||
+ | | ||
+ | Tasks: 177 (limit: 48800) | ||
+ | | ||
+ | CPU: 128ms | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Sep 26 15:01:28 redhat9.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Sep 26 15:01:28 redhat9.ittraining.loc httpd[7187]: | ||
+ | Sep 26 15:01:28 redhat9.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
+ | </ | ||
+ | |||
+ | Pour arrêter une Unité de service, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl stop httpd.service | ||
+ | |||
+ | [root@redhat9 ~]# systemctl status httpd.service | ||
+ | ○ httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | Process: 7187 ExecStart=/ | ||
+ | Main PID: 7187 (code=exited, | ||
+ | | ||
+ | CPU: 178ms | ||
+ | |||
+ | Sep 26 15:01:28 redhat9.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Sep 26 15:01:28 redhat9.ittraining.loc httpd[7187]: | ||
+ | Sep 26 15:01:28 redhat9.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
+ | Sep 26 15:02:54 redhat9.ittraining.loc systemd[1]: Stopping The Apache HTTP Server... | ||
+ | Sep 26 15:02:55 redhat9.ittraining.loc systemd[1]: httpd.service: | ||
+ | Sep 26 15:02:55 redhat9.ittraining.loc systemd[1]: Stopped The Apache HTTP Server. | ||
+ | </ | ||
+ | |||
+ | Pour désactiver un service au prochain démarrage du système, utilisez l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl disable httpd.service | ||
+ | Removed "/ | ||
+ | |||
+ | [root@redhat9 ~]# systemctl status httpd.service | ||
+ | ○ httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | |||
+ | Sep 26 15:01:28 redhat9.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Sep 26 15:01:28 redhat9.ittraining.loc httpd[7187]: | ||
+ | Sep 26 15:01:28 redhat9.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
+ | Sep 26 15:02:54 redhat9.ittraining.loc systemd[1]: Stopping The Apache HTTP Server... | ||
+ | Sep 26 15:02:55 redhat9.ittraining.loc systemd[1]: httpd.service: | ||
+ | Sep 26 15:02:55 redhat9.ittraining.loc systemd[1]: Stopped The Apache HTTP Server. | ||
+ | </ | ||
+ | |||
+ | ===5.2 - Gestion d' | ||
+ | |||
+ | Systemd permet l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# cat / | ||
+ | # This is a template for httpd instances. | ||
+ | # See httpd@.service(8) for more information. | ||
+ | |||
+ | [Unit] | ||
+ | Description=The Apache HTTP Server | ||
+ | After=network.target remote-fs.target nss-lookup.target | ||
+ | Documentation=man: | ||
+ | |||
+ | [Service] | ||
+ | Type=notify | ||
+ | Environment=LANG=C | ||
+ | Environment=HTTPD_INSTANCE=%i | ||
+ | ExecStartPre=/ | ||
+ | ExecStartPre=/ | ||
+ | ExecStartPre=/ | ||
+ | ExecStartPre=/ | ||
+ | ExecStart=/ | ||
+ | ExecReload=/ | ||
+ | # Send SIGWINCH for graceful stop | ||
+ | KillSignal=SIGWINCH | ||
+ | KillMode=mixed | ||
+ | PrivateTmp=true | ||
+ | OOMPolicy=continue | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | </ | ||
+ | |||
+ | Une instance créée à partir de ce gabarit devrait avoir un nom sous la forme suivante : | ||
+ | |||
+ | < | ||
+ | httpd@< | ||
+ | </ | ||
+ | |||
+ | Dans ce fichier on peut constater l' | ||
+ | |||
+ | * %n : est remplacé par le nom complet échappé de l' | ||
+ | * %N : est remplacé par le nom complet non-échappé de l' | ||
+ | * %p : est remplacé par le préfixe échappé de l' | ||
+ | * %P : est remplacé par le préfixe non-échappé de l' | ||
+ | * %i : est remplacé par le nom de l' | ||
+ | * %I : est remplacé par le nom de l' | ||
+ | * %f : est remplacé par le préfixe non-échappé ou le nom de l' | ||
+ | * %c : est remplacé par le CGroup de l' | ||
+ | * %u : est remplacé par le nom de l' | ||
+ | * %U : est remplacé par l'UID de l' | ||
+ | * %H : est remplacé par le nom d' | ||
+ | * %% : est remplacé" | ||
+ | |||
+ | Créez maintenant deux copies du fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# cp / | ||
+ | |||
+ | [root@redhat9 ~]# cp / | ||
+ | </ | ||
+ | |||
+ | Créez deux copies du fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# cp / | ||
+ | |||
+ | [root@redhat9 ~]# cp / | ||
+ | </ | ||
+ | |||
+ | Editez la directive **Listen** du fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# vi / | ||
+ | |||
+ | [root@redhat9 ~]# more / | ||
+ | # | ||
+ | # This is the main Apache HTTP server configuration file. It contains the | ||
+ | # configuration directives that give the server its instructions. | ||
+ | # See < | ||
+ | # In particular, see | ||
+ | # < | ||
+ | # for a discussion of each configuration directive. | ||
+ | # | ||
+ | # See the httpd.conf(5) man page for more information on this configuration, | ||
+ | # and httpd.service(8) on using and configuring the httpd service. | ||
+ | # | ||
+ | # Do NOT simply read the instructions in here without understanding | ||
+ | # what they do. They' | ||
+ | # consult the online docs. You have been warned. | ||
+ | # | ||
+ | # Configuration and logfile names: If the filenames you specify for many | ||
+ | # of the server' | ||
+ | # server will use that explicit path. If the filenames do *not* begin | ||
+ | # with "/", | ||
+ | # with ServerRoot set to '/ | ||
+ | # server as '/ | ||
+ | # interpreted as '/ | ||
+ | |||
+ | # | ||
+ | # ServerRoot: The top of the directory tree under which the server' | ||
+ | # configuration, | ||
+ | # | ||
+ | # Do not add a slash at the end of the directory path. If you point | ||
+ | # ServerRoot at a non-local disk, be sure to specify a local disk on the | ||
+ | # Mutex directive, if file-based mutexes are used. If you wish to share the | ||
+ | # same ServerRoot for multiple httpd daemons, you will need to change at | ||
+ | # least PidFile. | ||
+ | # | ||
+ | ServerRoot "/ | ||
+ | |||
+ | # | ||
+ | # Listen: Allows you to bind Apache to specific IP addresses and/or | ||
+ | # ports, instead of the default. See also the < | ||
+ | # directive. | ||
+ | # | ||
+ | # Change this to Listen on a specific IP address, but note that if | ||
+ | # httpd.service is enabled to run at boot time, the address may not be | ||
+ | # available when the service starts. | ||
+ | # page for more information. | ||
+ | # | ||
+ | #Listen 12.34.56.78: | ||
+ | Listen 8008 | ||
+ | PidFile / | ||
+ | # | ||
+ | # Dynamic Shared Object (DSO) Support | ||
+ | # | ||
+ | # To be able to use the functionality of a module which was built as a DSO you | ||
+ | # have to place corresponding `LoadModule' | ||
+ | # directives contained in it are actually available _before_ they are used. | ||
+ | --More--(19%) | ||
+ | [q] | ||
+ | </ | ||
+ | |||
+ | Editez la directive **Listen** du fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# vi / | ||
+ | |||
+ | [root@redhat9 ~]# more / | ||
+ | # | ||
+ | # This is the main Apache HTTP server configuration file. It contains the | ||
+ | # configuration directives that give the server its instructions. | ||
+ | # See < | ||
+ | # In particular, see | ||
+ | # < | ||
+ | # for a discussion of each configuration directive. | ||
+ | # | ||
+ | # See the httpd.conf(5) man page for more information on this configuration, | ||
+ | # and httpd.service(8) on using and configuring the httpd service. | ||
+ | # | ||
+ | # Do NOT simply read the instructions in here without understanding | ||
+ | # what they do. They' | ||
+ | # consult the online docs. You have been warned. | ||
+ | # | ||
+ | # Configuration and logfile names: If the filenames you specify for many | ||
+ | # of the server' | ||
+ | # server will use that explicit path. If the filenames do *not* begin | ||
+ | # with "/", | ||
+ | # with ServerRoot set to '/ | ||
+ | # server as '/ | ||
+ | # interpreted as '/ | ||
+ | |||
+ | # | ||
+ | # ServerRoot: The top of the directory tree under which the server' | ||
+ | # configuration, | ||
+ | # | ||
+ | # Do not add a slash at the end of the directory path. If you point | ||
+ | # ServerRoot at a non-local disk, be sure to specify a local disk on the | ||
+ | # Mutex directive, if file-based mutexes are used. If you wish to share the | ||
+ | # same ServerRoot for multiple httpd daemons, you will need to change at | ||
+ | # least PidFile. | ||
+ | # | ||
+ | ServerRoot "/ | ||
+ | |||
+ | # | ||
+ | # Listen: Allows you to bind Apache to specific IP addresses and/or | ||
+ | # ports, instead of the default. See also the < | ||
+ | # directive. | ||
+ | # | ||
+ | # Change this to Listen on a specific IP address, but note that if | ||
+ | # httpd.service is enabled to run at boot time, the address may not be | ||
+ | # available when the service starts. | ||
+ | # page for more information. | ||
+ | # | ||
+ | #Listen 12.34.56.78: | ||
+ | Listen 8009 | ||
+ | PidFile / | ||
+ | |||
+ | # | ||
+ | # Dynamic Shared Object (DSO) Support | ||
+ | # | ||
+ | # To be able to use the functionality of a module which was built as a DSO you | ||
+ | # have to place corresponding `LoadModule' | ||
+ | # directives contained in it are actually available _before_ they are used. | ||
+ | --More--(19%) | ||
+ | [q] | ||
+ | </ | ||
+ | |||
+ | Démarrez les deux services : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl start httpd@instance01.service | ||
+ | |||
+ | [root@redhat9 ~]# systemctl status httpd@instance01.service | ||
+ | ● httpd@instance01.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | Process: 7424 ExecStartPre=/ | ||
+ | Process: 7425 ExecStartPre=/ | ||
+ | Process: 7426 ExecStartPre=/ | ||
+ | Process: 7427 ExecStartPre=/ | ||
+ | Main PID: 7429 (httpd) | ||
+ | | ||
+ | Tasks: 177 (limit: 48800) | ||
+ | | ||
+ | CPU: 122ms | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Sep 26 15:14:24 redhat9.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Sep 26 15:14:25 redhat9.ittraining.loc httpd[7429]: | ||
+ | Sep 26 15:14:25 redhat9.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
+ | |||
+ | [root@redhat9 ~]# systemctl start httpd@instance02.service | ||
+ | |||
+ | [root@redhat9 ~]# systemctl status httpd@instance02.service | ||
+ | ● httpd@instance02.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | Process: 7614 ExecStartPre=/ | ||
+ | Process: 7615 ExecStartPre=/ | ||
+ | Process: 7616 ExecStartPre=/ | ||
+ | Process: 7617 ExecStartPre=/ | ||
+ | Main PID: 7618 (httpd) | ||
+ | | ||
+ | Tasks: 177 (limit: 48800) | ||
+ | | ||
+ | CPU: 113ms | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Sep 26 15:14:43 redhat9.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Sep 26 15:14:43 redhat9.ittraining.loc httpd[7618]: | ||
+ | Sep 26 15:14:43 redhat9.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
+ | </ | ||
+ | |||
+ | ===5.3 - Interdire la Modification du Statut d'un Service=== | ||
+ | |||
+ | Il est possible d' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl status httpd.service | ||
+ | ○ httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | |||
+ | Sep 26 15:01:28 redhat9.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Sep 26 15:01:28 redhat9.ittraining.loc httpd[7187]: | ||
+ | Sep 26 15:01:28 redhat9.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
+ | Sep 26 15:02:54 redhat9.ittraining.loc systemd[1]: Stopping The Apache HTTP Server... | ||
+ | Sep 26 15:02:55 redhat9.ittraining.loc systemd[1]: httpd.service: | ||
+ | Sep 26 15:02:55 redhat9.ittraining.loc systemd[1]: Stopped The Apache HTTP Server. | ||
+ | |||
+ | [root@redhat9 ~]# systemctl mask httpd.service | ||
+ | Created symlink / | ||
+ | |||
+ | [root@redhat9 ~]# systemctl enable httpd.service | ||
+ | Failed to enable unit: Unit file / | ||
+ | |||
+ | [root@redhat9 ~]# systemctl start httpd.service | ||
+ | Failed to start httpd.service: | ||
+ | </ | ||
+ | |||
+ | Pour autoriser de nouveau les modifications, | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl unmask httpd.service | ||
+ | Removed "/ | ||
+ | |||
+ | [root@redhat9 ~]# systemctl enable httpd.service | ||
+ | Created symlink / | ||
+ | |||
+ | [root@redhat9 ~]# systemctl start httpd.service | ||
+ | |||
+ | [root@redhat9 ~]# systemctl status httpd.service | ||
+ | ● httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | Main PID: 7896 (httpd) | ||
+ | | ||
+ | Tasks: 177 (limit: 48800) | ||
+ | | ||
+ | CPU: 99ms | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Sep 26 15:17:38 redhat9.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Sep 26 15:17:38 redhat9.ittraining.loc httpd[7896]: | ||
+ | Sep 26 15:17:38 redhat9.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
+ | </ | ||
+ | |||
+ | ----- | ||
+ | Copyright © 2024 Hugh Norris. |