Modification de RPM : Récupérer la base de données

Attention : vous n’êtes pas connecté(e). Votre adresse IP sera visible de tout le monde si vous faites des modifications. Si vous vous connectez ou créez un compte, vos modifications seront attribuées à votre propre nom d’utilisateur(rice) et vous aurez d’autres avantages.

La modification peut être annulée. Veuillez vérifier les différences ci-dessous pour voir si c’est bien ce que vous voulez faire, puis publier ces changements pour finaliser l’annulation de cette modification.

Version actuelle Votre texte
Ligne 1 : Ligne 1 :
{{Auteur|Adadov}}
{{EnCours|auteur=Adadov}}


Il arrive que la base de données RPM se mette en erreur, il est toujours utile d'avoir sous la main la procédure pour la remettre sur pieds.
This document provides an overview of how to deal with RPM database corruption.


== Supprimer le fichier de lock ==
== Removing stale locks ==
Si une commande RPM se bloque, plante ou disfonctionne, il faut commencer par vérifier les fichiers de lock. On peut le faire avec -CA sur la commande rpmdb_stat:


{{LxTerm|user=root|cd /var/lib/rpm
If an RPM command hangs, segfaults, or otherwise behaves abnormally during use then the first task is to check for stale lock files. This can be accomplished with -CA option to the rpmdb_stat command:
/usr/lib/rpm/rpmdb_stat -CA}}


== Reconstruire la base de données RPM ==
# cd /var/lib/rpm
Si après le nettoyage les problèmes persistes, la base est probablement corrompue. Il se peut aussi que vous ayez directement reçu un message vous annonçant la corruption ...
# /usr/lib/rpm/rpmdb_stat -CA


Dans ce cas il vous faudra reconstruire les metadonnées. Cette action est '''DESTRUCTIVE''' pensez bien à faire une sauvegarde avant en cas de soucis.
Look at the output under the sections headed 'Locks grouped by lockers' and 'Locks grouped by object'. If no RPM command is executing, then there should be no entries. The RPM DB format allows many processes to be concurrently reading *AND* writing to the DB, so there is no safe way for an RPM command to identify & remove a stale lock. Stale locks are typically a result of a process being killed in an abnormal manner (power loss, kernel crash, 'kill' from an impatient admin). The locks are maintained in a handful of files named with two initial underscores.
{{LxTerm|user=root|cd /var/lib
tar zcvf /var/preserve/rpmdb-`date +"%d%m%Y"`.tar.gz rpm}}


Ensuite on vérifie l'intégrité du fichier Packages.
Since there is generally no 100% reliable way to determine if an arbitrary application has a lock on the RPM db, the best time at which to clear the stale locks is while in single user mode. Thus to clean up stale lock files, the best course of action is to simply reboot the machine. If for some reason, it is not feasible to reboot the machine, then it is feasible to simply delete the files manually. Before doing this, one must ensure no application has any of the RPM database files open. This can be checked with the lsof command. For example, as root, ensure the following command shows no lines of output:
{{LxTerm|user=root|cd /var/lib/rpm
rm -f __db*      # to avoid stale locks
/usr/lib/rpm/rpmdb_verify Packages}}


Si vous obtenez une erreur, régénérez le.
# lsof | grep /var/lib/rpm
{{LxTerm|user=root|mv Packages Packages.orig
/usr/lib/rpm/rpmdb_dump Packages.orig {{!}} /usr/lib/rpm/rpmdb_load Packages
/usr/lib/rpm/rpmdb_verify Packages}}


Pour vérifier que tout est en ordre vous pouvez utiliser la fonction suivante:
== DB corruption recovery process ==
{{LxTerm|user=root|rpm -qa 1> /dev/null}}


Il ne restera plus qu'à reconstruire les métadonnées elles-mêmes:
If after cleaning up stale lock files, problems are still experianced, then it is likely some level of database corruption is present. The file that usually requires rebuilding is master package metadata file /var/lib/rpm/Packages, and following that the indexes will also need to be re-generated. Before doing any potentially destructive action *ALWAYS* take a backup of the RPM DB.
{{LxTerm|user=root|rpm -v --rebuilddb}}


Votre base de RPM devrait de nouveau fonctionner.
# cd /var/lib
# tar zcvf /var/preserve/rpmdb-`date +"%d%m%Y"`.tar.gz rpm


[[Category:RPM]]
Now verify the integrity of the Packages file:
[[Category:SysAdmin]]
 
# cd /var/lib/rpm
# rm -f __db*      # to avoid stale locks
# /usr/lib/rpm/rpmdb_verify Packages
 
If this reports any errors then a dump and load of the DB is required. After dumping, verify the integrity of the newly loaded Packages file:
 
# mv Packages Packages.orig
# /usr/lib/rpm/rpmdb_dump Packages.orig | /usr/lib/rpm/rpmdb_load Packages
# /usr/lib/rpm/rpmdb_verify Packages
 
If the Packages file now passes the verify step, then as an additional sanity check query all headers in the DB by doing, and watch for any messages sent to standard error (it helps to discard standard out when looking for this):
 
# rpm -qa 1> /dev/null
 
If this query passes without generating any messages to standard error, then it is time to rebuild the indexes by invoking:
 
# rpm -v --rebuilddb
 
At this point you should have a functioning RPM database again. If any of the recovery steps failed, then a bug should be reported. When creating the report, provide the tar.gz backup of the RPM DB as an attachment, along with any daily package list log files named /var/log/rpm*.
Notez bien que toutes les contributions à Adadov.net wiki peuvent être modifiées, transformées ou supprimées par d’autres utilisateurs. Si vous ne désirez pas que vos écrits soient modifiés contre votre gré, merci de ne pas les soumettre ici.
Vous nous promettez aussi que vous avez écrit ceci vous-même ou que vous l’avez copié d’une source placée dans le domaine public ou d’une ressource libre similaire (voir AdadovNet:Copyrights pour plus de détails). N’utilisez aucun travail sous droits d’auteur sans autorisation expresse !
Annuler Aide pour la modification (s’ouvre dans une nouvelle fenêtre)