Rebuild Corrupt Yum RPM Database

When installing packages via yum and the database is corrupt, the following message is displayed:

rpmdb: Thread/process 13903/140194607871904 failed: Thread died in Berkeley DB library
error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db3 -  (-30974)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Commands such as “yum clean all” also fail with this message.  To correct, move the RPM DB files to a temporary folder and rebuild the database with these 3 commands:

# mv /var/lib/rpm/__* ~
# rpm --rebuilddb
# rpm -qa | wc -l
500

If successful, it is safe to delete the __* files from your temporary folder.

Source: https://www.cloudibee.com/corrupt-rpmdb-and-recovery/

Leave a Reply

Your email address will not be published. Required fields are marked *