Ошибка невозможно открыть индекс packages используя db5 30973

Today, I was testing Nginx web server in a CentOS 7 VM. Unfortunately, the power has gone in the middle of the update process. Since I don’t have a UPS, my host system went down immediately. After few minutes, the power came, and I turned on the VM again and started the upgrade process. When I run the «yum update» command, I got this error message:

error: rpmdb: BDB0113 Thread/process 2196/139984719730496 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
CRITICAL:yum.main:

Error: rpmdb open failed

It seemes like YUM broke down. I couldn’t run any yum command. I haven’t faced this error before, and I didn’t know what to do. So, I headed over to the CentOS forum hoping to find a suitable solution to fix this issue. After a few searches over the forum, luckily I found a workaround. If you ever got into this problem, look nowhere and just do the following steps.

First backup the rpm database using command as root user:

# mv /var/lib/rpm/__db* /tmp

Then, run the following command:

# yum clean all

Now, run the update again:

# yum update
Loaded plugins: fastestmirror
Cleaning repos: base epel extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@server ~]# yum update
Loaded plugins: fastestmirror
base | 3.6 kB 00:00 
epel/x86_64/metalink | 5.0 kB 00:00 
epel | 4.3 kB 00:00 
extras | 3.4 kB 00:00 
updates | 3.4 kB 00:00 
(1/7): base/7/x86_64/group_gz | 155 kB 00:02 
(2/7): epel/x86_64/group_gz | 170 kB 00:04 
(3/7): extras/7/x86_64/primary_db | 191 kB 00:12 
(4/7): epel/x86_64/updateinfo | 809 kB 00:21 
(5/7): base/7/x86_64/primary_db | 5.6 MB 00:26 
(6/7): epel/x86_64/primary_db | 4.8 MB 00:46 
(7/7): updates/7/x86_64/primary_db | 7.8 MB 00:50 
Determining fastest mirrors
 * base: mirror.ehost.vn
 * epel: repo.ugm.ac.id
 * extras: mirror.ehost.vn
 * updates: mirror.dhakacom.com
Resolving Dependencies
--> Running transaction check
---> Package NetworkManager.x86_64 1:1.4.0-19.el7_3 will be updated
---> Package NetworkManager.x86_64 1:1.4.0-20.el7_3 will be an update
---> Package NetworkManager-adsl.x86_64 1:1.4.0-19.el7_3 will be updated
[...]
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package Arch Version Repository Size
================================================================================
Installing:
 kernel x86_64 3.10.0-514.26.2.el7 updates 37 M
 python2-libcomps x86_64 0.1.8-3.el7 epel 46 k
 replacing python-libcomps.x86_64 0.1.6-13.el7
Updating:
 NetworkManager x86_64 1:1.4.0-20.el7_3 updates 2.5 M
 NetworkManager-adsl x86_64 1:1.4.0-20.el7_3 updates 146 k
 NetworkManager-bluetooth x86_64 1:1.4.0-20.el7_3 updates 165 k
 NetworkManager-glib x86_64 1:1.4.0-20.el7_3 updates 385 k
 NetworkManager-libnm x86_64 1:1.4.0-20.el7_3 updates 443 k
 NetworkManager-team x86_64 1:1.4.0-20.el7_3 updates 147 k
 python-perf x86_64 3.10.0-514.26.2.el7 updates 4.0 M
 sudo x86_64 1.8.6p7-23.el7_3 updates 735 k
 systemd x86_64 219-30.el7_3.9 updates 5.2 M
 systemd-libs x86_64 219-30.el7_3.9 updates 369 k
 systemd-sysv x86_64 219-30.el7_3.9 updates 64 k
 tuned noarch 2.7.1-3.el7_3.2 updates 210 k
 xfsprogs x86_64 4.5.0-10.el7_3 updates 895 k
Removing:
 kernel x86_64 3.10.0-123.el7 @anaconda 127 M

Transaction Summary
================================================================================
Install 2 Packages
Upgrade 46 Packages
Remove 1 Package

Total download size: 84 M
Is this ok [y/d/N]: y

I type y to continue the update. Voila! Everything is worked as expected.

Finally, I cleaned the backup using command:

# rm -i /tmp/__db*

And, that’s all for now. Hope this helps.

Related read:

  • [Solved] — «error: rpmdbNextIterator: skipping» In Fedora Linux

25 comments

k3p3
September 11, 2018 — 9:06 am

Thank You.. It works


Reply

vicky
August 16, 2022 — 9:59 pm

rm -f /var/lib/rpm/__db*
db_verify /var/lib/rpm/Packages
rpm –rebuilddb
yum clean all


Reply

Marcos
September 16, 2018 — 10:18 pm

Thank You!!!


Reply

blah
September 21, 2018 — 11:40 am

thanks!


Reply

Nikhil Madhwani
October 5, 2018 — 2:56 am

Thank you!!!


Reply

Rob
November 2, 2018 — 8:58 am

Thanks, first link I look into and it worked!


Reply

tomaski
December 7, 2018 — 4:04 am

yeah, it does help, but in my case the issue just keeps returning… ¯_(ツ)_/¯


Reply

James
February 16, 2019 — 3:47 am

Praise you!


Reply

sk
February 16, 2019 — 12:22 pm

My pleasure.


Reply

robustrockster
July 24, 2019 — 4:18 pm

thanks it worked for me.
thanks indeed


Reply

sk
July 24, 2019 — 6:24 pm

You’re welcome. Glad it helped.


Reply

nabor
September 16, 2019 — 3:02 am

It works like charm! Thank you!


Reply

icycle
September 27, 2019 — 4:16 am

There’s another, simpler, solution that works for me:

rpm –rebuilddb


Reply

Yann
December 6, 2019 — 4:20 pm

Thank you !!!!!!!!!!!!


Reply

Tanaji
February 17, 2020 — 10:55 am

Thank you. Was able to resolve the issue.


Reply

Aitor
February 24, 2020 — 4:22 pm

Thank you, it worked on centos with directadmin.


Reply

Xd
March 20, 2020 — 11:32 am

Cool! Thank you


Reply

Muhammad Hafid
March 27, 2020 — 7:10 am

Thanks my problem solved


Reply

Ingram Braun
June 7, 2020 — 11:57 am

Works like a charm! Thank you!


Reply

maub_dash
July 9, 2020 — 7:53 pm

Thanks!


Reply

PK
January 3, 2021 — 9:37 am

Trying this with DNF now. It does NOT work. “DNF update” cannot even connect to some servers, and basic commands like sudo are missing. What’s happening?


Reply

MarkAnthony
January 7, 2021 — 4:56 pm

rpm –rebuilddb was fast and worked for me.

seems wise though to make note of both methods described here

thanks for this discussion


Reply

Saadedin
June 2, 2021 — 8:06 am

Works like a charm! Thank you!


Reply

DevOps
September 23, 2021 — 6:36 pm

Thank you, it working for me


Reply

Danny Lopez
September 21, 2022 — 7:58 pm

thanks, it Work


Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Sometimes when you attempt to update your CentOS server by running yum update, you might run into the error rpmdb open failed. It is a most common error.

When I ran into this error for the first time, it didn’t make sense to me and I thought maybe it’s the Firewall. I checked the firewall settings and checked the repositories but couldn’t find anything odd. I tried to reboot the system as well but the error remained the same:

error: rpmdb: BDB0113 Thread/process 2196/139984719730496 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
CRITICAL:yum.main:
Error: rpmdb open failed

k3p3
September 11, 2018 — 9:06 am

Thank You.. It works


Reply

vicky
August 16, 2022 — 9:59 pm

rm -f /var/lib/rpm/__db*
db_verify /var/lib/rpm/Packages
rpm –rebuilddb
yum clean all


Reply

Marcos
September 16, 2018 — 10:18 pm

Thank You!!!


Reply

blah
September 21, 2018 — 11:40 am

thanks!


Reply

Nikhil Madhwani
October 5, 2018 — 2:56 am

Thank you!!!


Reply

Rob
November 2, 2018 — 8:58 am

Thanks, first link I look into and it worked!


Reply

tomaski
December 7, 2018 — 4:04 am

yeah, it does help, but in my case the issue just keeps returning… ¯_(ツ)_/¯


Reply

James
February 16, 2019 — 3:47 am

Praise you!


Reply

sk
February 16, 2019 — 12:22 pm

My pleasure.


Reply

robustrockster
July 24, 2019 — 4:18 pm

thanks it worked for me.
thanks indeed


Reply

sk
July 24, 2019 — 6:24 pm

You’re welcome. Glad it helped.


Reply

nabor
September 16, 2019 — 3:02 am

It works like charm! Thank you!


Reply

icycle
September 27, 2019 — 4:16 am

There’s another, simpler, solution that works for me:

rpm –rebuilddb


Reply

Yann
December 6, 2019 — 4:20 pm

Thank you !!!!!!!!!!!!


Reply

Tanaji
February 17, 2020 — 10:55 am

Thank you. Was able to resolve the issue.


Reply

Aitor
February 24, 2020 — 4:22 pm

Thank you, it worked on centos with directadmin.


Reply

Xd
March 20, 2020 — 11:32 am

Cool! Thank you


Reply

Muhammad Hafid
March 27, 2020 — 7:10 am

Thanks my problem solved


Reply

Ingram Braun
June 7, 2020 — 11:57 am

Works like a charm! Thank you!


Reply

maub_dash
July 9, 2020 — 7:53 pm

Thanks!


Reply

PK
January 3, 2021 — 9:37 am

Trying this with DNF now. It does NOT work. “DNF update” cannot even connect to some servers, and basic commands like sudo are missing. What’s happening?


Reply

MarkAnthony
January 7, 2021 — 4:56 pm

rpm –rebuilddb was fast and worked for me.

seems wise though to make note of both methods described here

thanks for this discussion


Reply

Saadedin
June 2, 2021 — 8:06 am

Works like a charm! Thank you!


Reply

DevOps
September 23, 2021 — 6:36 pm

Thank you, it working for me


Reply

Danny Lopez
September 21, 2022 — 7:58 pm

thanks, it Work


Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Sometimes when you attempt to update your CentOS server by running yum update, you might run into the error rpmdb open failed. It is a most common error.

When I ran into this error for the first time, it didn’t make sense to me and I thought maybe it’s the Firewall. I checked the firewall settings and checked the repositories but couldn’t find anything odd. I tried to reboot the system as well but the error remained the same:

error: rpmdb: BDB0113 Thread/process 2196/139984719730496 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
CRITICAL:yum.main:
Error: rpmdb open failed

This error could appear because the YUM broke which could happen due to multiple reasons. So, in order to fix the issue, you can follow these steps:

  • Firstly, back-up your rpm database:
# sudo mv /var/lib/rpm/__db* /tmp
  • Next, run this command:
# sudo yum clean all
  • Now, the issue should be fixed and you can run the yum update:
# sudo yum update
  • Finally, clean the back up made previously:
# rm -rfi /tmp/__db*

Error: yum rpmdb open failed

# yum install -y lrzsz
----------
    error: rpmdb: BDB0113 Thread/process 3790/140203213080384 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
    CRITICAL:yum.main:
    
    Error: rpmdb open failed

# yum clean all
----------
    error: rpmdb: BDB0113 Thread/process 3790/140203213080384 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
    CRITICAL:yum.main:
    
    Error: rpmdb open failed

Solution

# cd /var/lib/rpm
# ll
----------
    total 101968
    -rw-r--r--. 1 root root  3047424 Aug  8 13:39 Basenames
    -rw-r--r--. 1 root root    20480 Aug  8 13:38 Conflictname
    -rw-r--r--. 1 root root   270336 Dec  3 09:10 __db.001
    -rw-r--r--. 1 root root    81920 Dec  3 09:10 __db.002
    -rw-r--r--. 1 root root  1318912 Dec  3 09:10 __db.003
    -rw-r--r--. 1 root root  1355776 Aug  8 13:39 Dirnames
    -rw-r--r--. 1 root root    16384 Aug  8 13:39 Group
    -rw-r--r--. 1 root root    12288 Aug  8 13:39 Installtid
    -rw-r--r--. 1 root root    24576 Aug  8 13:39 Name
    -rw-r--r--. 1 root root    16384 Jul 13 16:24 Obsoletename
    -rw-r--r--. 1 root root 95866880 Aug  8 13:39 Packages
    -rw-r--r--. 1 root root  2277376 Aug  8 13:39 Providename
    -rw-r--r--. 1 root root   151552 Aug  8 13:39 Requirename
    -rw-r--r--. 1 root root    49152 Aug  8 13:39 Sha1header
    -rw-r--r--. 1 root root    40960 Aug  8 13:39 Sigmd5
    -rw-r--r--. 1 root root     8192 Jul 13 16:19 Triggername
# rm __db.* -rf
# rpm --rebuilddb
# ll
----------
    total 76380
    -rw-r--r--. 1 root root  2613248 Dec  3 09:18 Basenames
    -rw-r--r--. 1 root root    20480 Dec  3 09:18 Conflictname
    -rw-r--r--. 1 root root  1318912 Dec  3 09:18 Dirnames
    -rw-r--r--. 1 root root     8192 Dec  3 09:18 Group
    -rw-r--r--. 1 root root    12288 Dec  3 09:18 Installtid
    -rw-r--r--. 1 root root    24576 Dec  3 09:18 Name
    -rw-r--r--. 1 root root    16384 Dec  3 09:18 Obsoletename
    -rw-r--r--. 1 root root 70184960 Dec  3 09:18 Packages
    -rw-r--r--. 1 root root  2179072 Dec  3 09:18 Providename
    -rw-r--r--. 1 root root   155648 Dec  3 09:18 Requirename
    -rw-r--r--. 1 root root    40960 Dec  3 09:18 Sha1header
    -rw-r--r--. 1 root root    32768 Dec  3 09:18 Sigmd5
    -rw-r--r--. 1 root root     8192 Dec  3 09:18 Triggername
# yum clean all
----------
    Loaded plugins: fastestmirror
    Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
    Cleaning repos: base elrepo epel extras google-cloud-compute google-cloud-sdk mongodb-org-3.2 updates
    Cleaning up everything
    Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
    Cleaning up list of fastest mirrors

END

Is RedHat error “rpmdb open failed” giving you trouble?

At Bobcares, we offer solutions for every query, big and small, as a part of our Server Management Service.

Let’s take a look at how our Support Team recently helped a customer with the very common “rpmdb open failed” error.

What is RedHat error: “rpmdb open failed”?

The rpmdb open failed error often occurs when you attempt to update your system again after it was interrupted earlier. This is when you find yourself facing the following error message:

error: rpmdb: BDB0113 Thread/process 2196/139984719730496 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 
CRITICAL:yum.main: 
Error: rpmdb open failed

We will also not be able to run the rpm query, resulting in the following error message:

[root@testvm~]# rpm -qa 
error: rpmdb: BDB0113 Thread/process 7924/139979327153984 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 7924/139979327153984 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 
[root@testvm ~]# rpm -Va 
error: rpmdb: BDB0113 Thread/process 7924/139979327153984 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 7924/139979327153984 failed: BDB1507 Thread died in Berkeley DB library e
rror: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
 error: cannot open Packages database in /var/lib/rpm 
error: rpmdb: BDB0113 Thread/process 7924/139979327153984 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 
[root@testvm~]#

The error is a result of a corrupt rmd or RPM database. Fortunately, our Support Team has come up with an easy resolution for this specific issue.

How to resolve RedHat error: “rpmdb open failed”

  1. First, we will create a backup directory where we can dump the rpmdb backup file as seen below:
    # mkdir /tmp/rpm_db_bak
  2. Then, we will back up the files in the newly created directory in the previous step in the /tmp folder.
    # mv /var/lib/rpm/__db* /tmp/rpm_db_bak
  3. Next, we have to rebuild the rpmdb by executing these commands:
    # rpm --rebuilddb -vv
    # rpmdb_verify Packages
  4. After that, we will clean the yum cache by running this command:
    # yum clean all
  5. Then, we will run the yum update command again in order to fetch and apply the updates from the repositories.

[Stuck with a different query? We are available 24/7.]

Conclusion

In brief, the skilled Support Engineers at Bobcares demonstrated how to resolve the “rpmdb open failed” error with ease.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

Profile picture for user Олег

Oracle Linux

Свежий баг. Редкий, но встречается. У меня случился на Oracle Linux.

Симптомы только косвенные. Началась утечка CPU на виртуальной машине. Прошло несколько дней, гипервизор стал жаловаться на процессор:

cpu

Смотрю статистику использования CPU гипервизора и вижу такую картину:

cpu

Видно утечку, ищем виновника.

linux

Графики производительности помогают легко найти виртуальную машину с утечкой CPU. Заглянем ей в консоль.

cpu

Опа, процессоры сожраны запросами к RPM. Выполняю:

rpm -qa

Запрос зависает, Ctrl + C со скрежетом убиваем текущий процесс. Заново делаю тот же запрос, вот и виновник торжества:

ошибка: rpmdb: BDB0113 Thread/process 9817/139781811808320 failed: BDB1507 Thread died in Berkley DB library
ошибка: ошибка(5)  db_30973 из dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
ошибка: невозможно открыть индекс Packages используя db5 -  (-30973)

rpm

Быстрое решение проблемы

Пересоздаём базу RPM.

rm -f /var/lib/rpm/__db*
rpm -vv --rebuilddb

Немного терпения.

cpu

С облегчением.

cpu

Еще больше вариантов восстановления

http://wiki.rosalab.ru/ru/index.php/Если_упала_база_RPM

  1. rm -f /var/lib/rpm/__db.*
    /usr/lib/rpm/bin/rpmdbchk
    
  2. db52_recover -vh /var/lib/rpm
  3. perl -MURPM -e 'URPM::DB::convert("/", "btree", 1, 1)'
  4. rm -f /var/lib/rpm/__db*
    rpm -vv --rebuilddb
  5. urpmi.recover --list-safe
    # (найти стабильное состояние и откатить на нужное количество транзакций, обозначенных датами)
    urpmi.recover --transactions --rollback 3
    
  6. # копируем из /var/log последний здоровый rpmpkgs в удобное место.
    cp /var/log/rpmpkgs /home/username
    cp /var/lib/rpm/ /var/lib/rpm-stored
    # чистим
    rm -f /var/lib/rpm/__db*
    rm -f /var/lib/rpm/Packages
    rm -f /var/lib/rpm/log/log*
    # создаём БД
    rpm -vv --rebuilddb
    # проверим
    urpmi wget,urpmi
    # скачаем все пакеты
    cat /home/username/rpmpkgs | xargs urpmi --no-install
    # поставим
    cat /home/username/rpmpkgs | xargs urpmi --justdb
    # или
    cat /home/username/rpmpkgs | xargs rpm -i -v --nodeps --noscripts --notriggers --justdb --excludepath /

Понравилась статья? Поделить с друзьями:
  • Ошибка недостаточно места на диске для завершения операции
  • Ошибка невозможно открыть wia источник
  • Ошибка недостаточно места в стеке
  • Ошибка невозможно открыть c users
  • Ошибка недостаточно места в папке