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

De Adadov.net wiki
Article en cours de rédaction ou de modification !
WorkInProgress.png
Le présent article est actuellement en cours de rédaction ou de modification.
Adressez-vous à la personne en charge pour toute proposition ou modification.
Auteur / Editeur : Adadov
Dernière édition : 14/08/2018


This document provides an overview of how to deal with RPM database corruption.

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:

[root@linux] # cd /var/lib/rpmdblclick to copy
[root@linux] # /usr/lib/rpm/rpmdb_stat -CA

DB corruption recovery process

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 ...

Dans ce cas il vous faudra reconstruire les metadonnées. Cette action est DESTRUCTIVE pensez bien à faire une sauvegarde avant en cas de soucis.

[root@linux] # cd /var/libdblclick to copy
[root@linux] # tar zcvf /var/preserve/rpmdb-`date +"%d%m%Y"`.tar.gz rpm

Ensuite on vérifie l'intégrité du fichier Packages.

[root@linux] # cd /var/lib/rpmdblclick to copy
[root@linux] # rm -f __db* # to avoid stale locks
[root@linux] # /usr/lib/rpm/rpmdb_verify Packages

Si vous obtenez une erreur, régénérez le.

[root@linux] # mv Packages Packages.origdblclick to copy
[root@linux] # /usr/lib/rpm/rpmdb_dump Packages.orig

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):

[root@linux] # rpm -qa 1> /dev/nulldblclick to copy

If this query passes without generating any messages to standard error, then it is time to rebuild the indexes by invoking:

[root@linux] # rpm -v --rebuilddbdblclick to copy

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*.