Server power outages could cause several problems and one of them is braking YUM manager. When the server is going down while YUM processing (even in background) repo task you will probably face a problem (a very messy situation with yum failure).
Requesting YUM / RPM:
[root@universal ~]# rpm -qa
You are usually see:
error: rpmdb: BDB0113 Thread/process 11074/47686246043008 failed: BDB1507 Thread died in Berkeley DB library error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery error: cannot open Packages index using db5 - (-30973) error: cannot open Packages database in /var/lib/rpm error: rpmdb: BDB0113 Thread/process 11074/47686246043008 failed: BDB1507 Thread died in Berkeley DB library error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery error: cannot open Packages database in /var/lib/rpm
The problem is a corrupted rpm database, mostly coming into existence because of an aborted update process.
How this YUM braking could be fixed?
You may fix this by cleaning out entire RPM database and then rebuilding the entire database again. To minimize risk, we should make a backup of files in /var/lib/rpm/
YUM step-by-step fixing
1. We will create a backup directory in which we need to copy the rpmdb backup using command:
[root@universal ~]# mkdir /tmp/rpm_db_bak
2. Backing up the rpmdb files in the created backup directory in /tmp:
[root@universal ~]# mv /var/lib/rpm/__db* /tmp/rpm_db_bak
3. Flushing all the yum cache by the following command:
[root@universal ~]# yum clean all
4. Start building new rpmdb
We will do this by running the yum update command. It will rebuild the rpmdb and will fetch and apply the updates from the repositions:
[root@universal ~]# yum update
Allow some time for this process:
[root@universal ~]# yum update Loaded plugins: fastestmirror Determining fastest mirrors [skipped] (65/67): vim-filesystem-7.4.160-6.el7_6.x86_64.rpm | 10 kB 00:00:00 (66/67): vim-minimal-7.4.160-6.el7_6.x86_64.rpm | 437 kB 00:00:00 (67/67): kernel-3.10.0-957.27.2.el7.x86_64.rpm | 48 MB 00:00:10 ------------------------------------------------------------------------------------------------------------------------------- Total 11 MB/s | 157 MB 00:00:14 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : 32:bind-license-9.9.4-74.el7_6.2.noarch 1/134 Updating : selinux-policy-3.13.1-229.el7_6.15.noarch 2/134 [skipped] nginx.x86_64 2:1.16.1-1.el7.ngx proftpd.x86_64 0:1.3.5e-5.el7 python.x86_64 0:2.7.5-80.el7_6 python-libs.x86_64 0:2.7.5-80.el7_6 python-perf.x86_64 0:3.10.0-957.27.2.el7 selinux-policy.noarch 0:3.13.1-229.el7_6.15 selinux-policy-targeted.noarch 0:3.13.1-229.el7_6.15 systemd.x86_64 0:219-62.el7_6.9 systemd-libs.x86_64 0:219-62.el7_6.9 systemd-python.x86_64 0:219-62.el7_6.9 systemd-sysv.x86_64 0:219-62.el7_6.9 tuned.noarch 0:2.10.0-6.el7_6.4 tzdata.noarch 0:2019b-1.el7 vim-common.x86_64 2:7.4.160-6.el7_6 vim-enhanced.x86_64 2:7.4.160-6.el7_6 vim-filesystem.x86_64 2:7.4.160-6.el7_6 vim-minimal.x86_64 2:7.4.160-6.el7_6 Complete!
Great! You are now fine!