Any way to replace damaged RPM database.

Issues related to applications and software problems and general support
Post Reply
gosha
Posts: 6
Joined: 2021/01/22 07:42:09

Any way to replace damaged RPM database.

Post by gosha » 2021/01/22 22:06:24

Hello

I have a number of servers with CentOS 8.3.2011. One of them after a latest update with kernel packages got a damage to RPM database.

[root@ispcd ~]# yum update
error: db5 error(-30973) from dbenv->open: 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: Error: rpmdb open failed

Deleting __db.* and rebuilding the database did not help. dump | load of Packages file did not help a lot too. Is there any way to recreate this database?

sml
Posts: 246
Joined: 2020/01/17 09:01:44

Re: Any way to replace damaged RPM database.

Post by sml » 2021/01/23 11:37:33

Sometimes, lockfiles would prevent rebuilding the RPM database. So try

Code: Select all

rm -f /var/lib/rpm/.*.lock
restorecon -r /var/lib/rpm
rpm --rebuilddb
dnf clean all

gosha
Posts: 6
Joined: 2021/01/22 07:42:09

Re: Any way to replace damaged RPM database.

Post by gosha » 2021/01/23 22:00:57

Hello

Thanks for the advice but seems not really helps.

[root@ispcd ~]# rm -f /var/lib/rpm/.*.lock
[root@ispcd ~]# restorecon -r /var/lib/rpm
[root@ispcd ~]# rpm --rebuilddb
error: rpmdb: BDB0058 page 6997: illegal page type or format
error: rpmdb: BDB0061 PANIC: Invalid argument
error: rpmdb: BDB3016 Packages: pgin failed for page 6997
error: db5 error(-30973) from dbcursor->c_get: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: rpmdb: BDB0060 PANIC: fatal region error detected; run recovery
error: db5 error(-30973) from dbcursor->c_close: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: rpmdb: BDB0060 PANIC: fatal region error detected; run recovery
error: db5 error(-30973) from db->close: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: rpmdb: BDB1581 File handles still open at environment close
error: rpmdb: BDB1582 Open file handle: /var/lib/rpm/Packages
error: rpmdb: BDB0060 PANIC: fatal region error detected; run recovery
error: db5 error(-30973) from dbenv->close: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
[root@ispcd ~]# rpm -qa | wc -l
370


Seems that the information in the database has been restored only partly. Packages amount should be about 900+

sml
Posts: 246
Joined: 2020/01/17 09:01:44

Re: Any way to replace damaged RPM database.

Post by sml » 2021/01/24 15:45:40

Did you get the same error messages as the last time? If not, let's try it once again:

Code: Select all

rm -f /var/lib/rpm/{.*.lock,__db.*}
rpm --rebuilddb
If this still doesn't help, try running db_recover from libdb-utils directly. It has the -v option that makes the output more verbose than rpm -v, but less so than rpm -vv. Even if it won't repair the database, it may give some additional hints.

Code: Select all

db_recover -v -h /var/lib/rpm
The most verbose option is

Code: Select all

rpm -vv --rebuilddb
This will spit out lots of debug output.

Post Reply

Return to “CentOS 8 - General Support”