Redhat - conteneur de configuration (stockage persistant et démarrage automatique)

Informations sur le serveur d'enregistrement

Enregistrer l'adresse du serveur register.domain250.example.com

Utilisez admin comme nom d'utilisateur et redhat321 comme informations d'identification pour le registre d'images

#Configurer le conteneur pour qu'il démarre automatiquement

À l'aide du miroir rsyslog sur le serveur de registre, créez un conteneur nommé logserver

Pour les utilisateurs wallah, configurez un service systemd

Le service est nommé container-logserver et démarre automatiquement au redémarrage du système sans intervention

 
# Configurer le stockage persistant pour le conteneur

Prolongez le service de la tâche précédente en

Configurez le journal journald du système hôte pour conserver les données lors des redémarrages du système et redémarrez le service de journalisation

Copiez tous les fichiers avec *.journal dans le répertoire hôte /var/log/journal vers /home/wallah/container_logfile

Configurez le service pour monter automatiquement /home/wallah/container_logfile sur /var/log/journal dans le conteneur au démarrage

[root@node1 ~]# man journald.conf
[root@node1 ~]# vim /etc/systemd/journald.conf
[root@node1 ~]# ll -d /run/log/journal/
drwxr-sr-x. 4 root systemd-journal 80 May 12 18:11 /run/log/journal/
[root@node1 ~]# mkdir /var/log/journal
[root@node1 ~]# ll -d /var/log/journal
drwxr-xr-x. 2 root root 6 May 12 18:57 /var/log/journal
[root@node1 ~]# chmod -R g+s /var/log/journal
[root@node1 ~]# ll -d /var/log/journal
drwxr-sr-x. 2 root root 6 May 12 18:57 /var/log/journal
[root@node1 ~]# chown root:systemd-journal /var/log/journal
[root@node1 ~]# ll -d /var/log/journal
drwxr-sr-x. 2 root systemd-journal 6 May 12 18:57 /var/log/journal
[root@node1 ~]# systemctl restart systemd-journald
[root@node1 ~]# systemctl enable systemd-journald
The unit files have no installation config (WantedBy, RequiredBy, Also, Alias
settings in the [Install] section, and DefaultInstance for template units).
This means they are not meant to be enabled using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
   .wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
   a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
   D-Bus, udev, scripted systemctl call, ...).
4) In case of template units, the unit is meant to be enabled with some
   instance name specified.
[root@node1 ~]# systemctl status systemd-journald
● systemd-journald.service - Journal Service
   Loaded: loaded (/usr/lib/systemd/system/systemd-journald.service; static; ve>
   Active: active (running) since Fri 2023-05-12 18:59:26 EDT; 16s ago
     Docs: man:systemd-journald.service(8)
           man:journald.conf(5)
 Main PID: 1505 (systemd-journal)
   Status: "Processing requests..."
    Tasks: 1 (limit: 11345)
   Memory: 1.3M
   CGroup: /system.slice/systemd-journald.service
           └─1505 /usr/lib/systemd/systemd-journald

May 12 18:59:26 node1.domain250.example.com systemd-journald[1505]: Journal sta>
May 12 18:59:26 node1.domain250.example.com systemd-journald[1505]: System jour>
[root@node1 ~]# cp /var/log/journal/*/*.journal /home/wallah/container_logfile
[root@node1 ~]# cd /home/wallah
[root@node1 wallah]# ll
total 0
drwxr-xr-x. 2 wallah wallah 28 May 12 19:00 container_logfile
[root@node1 wallah]# cd container_logfile/
[root@node1 container_logfile]# ll
total 8192
-rw-r-----. 1 root root 8388608 May 12 19:00 system.journal
[root@node1 container_logfile]# chown wallah ~wallah
[root@node1 container_logfile]# ll
total 8192
-rw-r-----. 1 root root 8388608 May 12 19:00 system.journal
[root@node1 container_logfile]# chown -R wallah ~wallah
[root@node1 container_logfile]# ll
total 8192
-rw-r-----. 1 wallah root 8388608 May 12 19:00 system.journal
[root@node1 container_logfile]# ssh wallah@localhost
Activate the web console with: systemctl enable --now cockpit.socket

This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register

[wallah@node1 ~]$ podman login registry.domain250.example.com
Username: admin
Password: 
Login Succeeded!
[wallah@node1 ~]$ podman search registry.domain250.example.com/
INDEX         NAME                                               DESCRIPTION   STARS   OFFICIAL   AUTOMATED
example.com   registry.domain250.example.com/rhel8/mariadb-103                 0                  
example.com   registry.domain250.example.com/rhel8/httpd-24                    0                  
example.com   registry.domain250.example.com/library/nginx                     0                  
example.com   registry.domain250.example.com/ubi7/ubi                          0                  
example.com   registry.domain250.example.com/ubi8/ubi                          0                  
example.com   registry.domain250.example.com/rhel8/rsyslog                     0                  
[wallah@node1 ~]$ podman run -d --name logserver -v /home/wallah/container_logfile:/var/log/journal:Z registry.domain250.example.com/rhel8/rsyslog 
Trying to pull registry.domain250.example.com/rhel8/rsyslog...
Getting image source signatures
Copying blob d23202532999 done  
Copying blob b6efbecbebd6 done  
Copying blob 88afac75a773 done  
Copying config 1ca52ef7a2 done  
Writing manifest to image destination
Storing signatures
e0012a874499ca23600c9744fbd5d6cd0fd054f824924798b8d843c68eeac62a
[wallah@node1 ~]$ podman ps
CONTAINER ID  IMAGE                                                COMMAND          CREATED        STATUS            PORTS  NAMES
e0012a874499  registry.domain250.example.com/rhel8/rsyslog:latest  /bin/rsyslog.sh  7 seconds ago  Up 6 seconds ago         logserver
[wallah@node1 ~]$ podman stop logserver
e0012a874499ca23600c9744fbd5d6cd0fd054f824924798b8d843c68eeac62a
[wallah@node1 ~]$ podman ps
CONTAINER ID  IMAGE  COMMAND  CREATED  STATUS  PORTS  NAMES
[wallah@node1 ~]$ loginctl enable-linger 
[wallah@node1 ~]$ mkdir -p ~/.config/systemd/user
[wallah@node1 ~]$ cd ~/.config/systemd/user
[wallah@node1 user]$ ll
total 0
[wallah@node1 user]$ podman generate systemd -n logserver -f
/home/wallah/.config/systemd/user/container-logserver.service
[wallah@node1 user]$ systemctl enable --user --now container-logserver.service
Created symlink /home/wallah/.config/systemd/user/multi-user.target.wants/container-logserver.service → /home/wallah/.config/systemd/user/container-logserver.service.
Created symlink /home/wallah/.config/systemd/user/default.target.wants/container-logserver.service → /home/wallah/.config/systemd/user/container-logserver.service.
[wallah@node1 user]$ podman ps
CONTAINER ID  IMAGE                                                COMMAND          CREATED        STATUS            PORTS  NAMES
e0012a874499  registry.domain250.example.com/rhel8/rsyslog:latest  /bin/rsyslog.sh  3 minutes ago  Up 6 seconds ago         logserver
[wallah@node1 user]$ podman images
REPOSITORY                                     TAG      IMAGE ID       CREATED       SIZE
registry.domain250.example.com/rhel8/rsyslog   latest   1ca52ef7a2f4   2 years ago   232 MB

Je suppose que tu aimes

Origine blog.csdn.net/qq_53376718/article/details/130652834
conseillé
Classement