Tuesday, 24 January 2023

How to Recover Corrupt RPM Database on CentOS 8

Sometime rpm database corrupt message displays during working with RPM or YUM/DNF as shown in below screen. So, rpm database rebuilding requires to work further with RPM or YUM/DNF.

[root@linuxcnf ~]# dnf reinstall iperf
error: db5 error(12) from dbenv->open: Cannot allocate memory
error: db5 error(22) from dbenv->close: Invalid argument
error: cannot open Packages index using db5 - Cannot allocate memory (12)
error: cannot open Packages database in /var/lib/rpm
Error: Error: rpmdb open failed
[root@linuxcnf ~]#

This article describes How to Recover Corrupt RPM Database on CentOS 8.
Step 1. Backup RPM Database: Run the following command to take backup of existing database in case any unforeseen issue occur.
[root@linuxcnf ~]# mv /var/lib/rpm/__db.00* /tmp/
[root@linuxcnf ~]#
Step 2. Clean YUM Repository: Run the following command to clean all dnf repository data:
[root@linuxcnf ~]# dnf clean all
29 files removed
[root@linuxcnf ~]#
Step 3. Validate: Now try to install/reinstall any packages to confirm if the issue is resolved or not:
[root@linuxcnf ~]# dnf reinstall iperf
[root@linuxcnf ~]#
Done!!! Now the RPM database issue resolved on CentOS 8. Once we remove existing database the YUM/DNF automatically rebuild/create database as when we run any yum/dnf command.

No comments:

Post a Comment