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

Cookbook version

cookbook ‘lvm’, ‘~> 4.5.3’

Chef-client version

chef-14.7.17

Platform Details

redhat 7

Scenario:

We often see Thread died in Berkeley DB library error: db5 error(-30973) when chef-client attempt so run across our environments. We would need to do the following on the OS to fix issue: rm -f /var/lib/rpm/__db* and then rpm —rebuilddb

Details on this one:
yum_package[lvm2] (lvm::default line 20) had an error: RuntimeError: yum-helper.py had stderr/stdout output: error: rpmdb: BDB0113 Thread/process 98402/140067491477568 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 98402/140067491477568 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 Traceback (most recent call last): File «/opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/provider/package/yum/yum_helper.py», line 203, in query(command) File «/opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/provider/package/yum/yum_helper.py», line 88, in query enabled_repos = base.repos.listEnabled() File «/usr/lib/python2.7/site-packages/yum/init.py», line 1071, in repos = property(fget=lambda self: self._getRepos(), File «/usr/lib/python2.7/site-packages/yum/init.py», line 686, in _getRepos self.conf # touch the config class first File «/usr/lib/python2.7/site-packages/yum/init.py», line 1079, in conf = property(fget=lambda self: self._getConfig(), File «/usr/lib/python2.7/site-packages/yum/init.py», line 349, in _getConfig startupconf = config.readStartupConfig(fn, root, releasever) File «/usr/lib/python2.7/site-packages/yum/config.py», line 1115, in readStartupConfig startupconf.distroverpkg) File «/usr/lib/python2.7/site-packages/yum/config.py», line 1260, in _getsysver raise Errors.YumBaseError(«Error: » + str(e)) yum.Errors.YumBaseError: Error: rpmdb open failed

This one would come from:
https://supermarket.chef.io/cookbooks/lvm

https://github.com/chef-cookbooks/lvm/blob/master/recipes/default.rb

LINE 20 it attempts is:
package ‘lvm2’

Steps to Reproduce:

[If you are filing an issue what are the things we need to do in order to repro your problem? How are you using this cookbook or any resources it includes?]

Expected Result:

chef-client run successful

Actual Result:

chef-client fails once it get to lvm2 package

Причина база данных rpm повреждена.
Просто измените базу данных.
Выполните команду cd /var/lib/rpm

Выполните команду cd /var/lib/rpm
ls
Basenames Conflictname __db.001 __db.002 __db.003 Dirnames Group Installtid Name Obsoletename Packages Providename Requirename Sha1header Sigmd5 Triggername

Проверим:

[root@isTester-Idoxu rpm]# ll
total 142484
-rw-r--r--. 1 root root 3051520 Nov 4 2020 Basenames
-rw-r--r--. 1 root root 16384 Oct 30 2020 Conflictname
-rw-r--r-- 1 root root 286720 Nov 8 17:55 __db.001
-rw-r--r-- 1 root root 90112 Nov 8 17:55 __db.002
-rw-r--r-- 1 root root 1318912 Nov 8 17:55 __db.003
-rw-r--r--. 1 root root 2072576 Nov 4 2020 Dirnames
-rw-r--r--. 1 root root 20480 Nov 4 2020 Group
-rw-r--r--. 1 root root 16384 Nov 4 2020 Installtid
-rw-r--r--. 1 root root 36864 Nov 4 2020 Name
-rw-r--r--. 1 root root 16384 Nov 2 2020 Obsoletename
-rw-r--r--. 1 root root 136822784 Nov 4 2020 Packages
-rw-r--r--. 1 root root 1888256 Nov 4 2020 Providename
-rw-r--r--. 1 root root 253952 Nov 4 2020 Requirename
-rw-r--r--. 1 root root 73728 Nov 4 2020 Sha1header
-rw-r--r--. 1 root root 40960 Nov 4 2020 Sigmd5
-rw-r--r--. 1 root root 8192 Oct 30 2020 Triggername

Удалите поврежденный файл базы данных:

[root@isTester-Idoxu rpm]# rm -rf __db.00*
[root@isTester-Idoxu rpm]# ll
total 140964
-rw-r--r--. 1 root root 3051520 Nov 4 2020 Basenames
-rw-r--r--. 1 root root 16384 Oct 30 2020 Conflictname
-rw-r--r--. 1 root root 2072576 Nov 4 2020 Dirnames
-rw-r--r--. 1 root root 20480 Nov 4 2020 Group
-rw-r--r--. 1 root root 16384 Nov 4 2020 Installtid
-rw-r--r--. 1 root root 36864 Nov 4 2020 Name
-rw-r--r--. 1 root root 16384 Nov 2 2020 Obsoletename
-rw-r--r--. 1 root root 136822784 Nov 4 2020 Packages
-rw-r--r--. 1 root root 1888256 Nov 4 2020 Providename
-rw-r--r--. 1 root root 253952 Nov 4 2020 Requirename
-rw-r--r--. 1 root root 73728 Nov 4 2020 Sha1header
-rw-r--r--. 1 root root 40960 Nov 4 2020 Sigmd5
-rw-r--r--. 1 root root 8192 Oct 30 2020 Triggername

Повторно создайте файл базы данных:

rpm --rebuilddb
yum
Loaded plugins: fastestmirror, langpacks
You need to give some command
Usage: yum [options] COMMAND

Проверьте, успешно ли выполнено создание:

[root@isTester-Idoxu rpm]# ll
total 86052
-rw-r--r-- 1 root root 2846720 Nov 8 17:58 Basenames
-rw-r--r-- 1 root root 8192 Nov 8 17:58 Conflictname
-rw-r--r-- 1 root root 286720 Nov 8 17:58 __db.001
-rw-r--r-- 1 root root 90112 Nov 8 17:58 __db.002
-rw-r--r-- 1 root root 57344 Nov 8 17:58 __db.003
-rw-r--r-- 1 root root 1327104 Nov 8 17:58 Dirnames
-rw-r--r-- 1 root root 24576 Nov 8 17:58 Group
-rw-r--r-- 1 root root 16384 Nov 8 17:58 Installtid
-rw-r--r-- 1 root root 40960 Nov 8 17:58 Name
-rw-r--r-- 1 root root 16384 Nov 8 17:58 Obsoletename
-rw-r--r-- 1 root root 81248256 Nov 8 17:58 Packages
-rw-r--r-- 1 root root 1957888 Nov 8 17:58 Providename
-rw-r--r-- 1 root root 217088 Nov 8 17:58 Requirename
-rw-r--r-- 1 root root 69632 Nov 8 17:58 Sha1header
-rw-r--r-- 1 root root 45056 Nov 8 17:58 Sigmd5
-rw-r--r-- 1 root root 8192 Nov 8 17:58 Triggername

все готово!

Environment

  • Red Hat Enterprise Linux (RHEL) 6
  • Red Hat Enterprise Linux (RHEL) 7
  • Red Hat Enterprise Linux (RHEL) 8

Issue

  • Recurring rpm database corruption
  • Stale lock files are being left behind in /var/lib/rpm
  • rpm commands are failing with messages similar to:

    # rpm -qa
    error: rpmdb: BDB0113 Thread/process 5691/140201285396544 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 5691/140201285396544 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
    

Resolution

Disclaimer: This utility is meant to be used at the request of support and is not officially supported by Red Hat. Any issues seen with this utility will be handled, if possible, by one of the few engineers associated with it’s creation and not by Bugzilla

Configure the repository

  • RHEL 6:

    # curl https://people.redhat.com/kwalker/repos/rpm-deathwatch/rhel6/rpm-deathwatch-rhel-6.repo -o /etc/yum.repos.d/rpm-deathwatch.repo
    
  • RHEL 7:

    # curl https://people.redhat.com/kwalker/repos/rpm-deathwatch/rhel7/rpm-deathwatch-rhel-7.repo -o /etc/yum.repos.d/rpm-deathwatch.repo
    
  • RHEL 8:

    # curl https://people.redhat.com/kwalker/repos/rpm-deathwatch/rhel8/rpm-deathwatch-rhel-8.repo -o /etc/yum.repos.d/rpm-deathwatch.repo
    

Install required packages

  • You will need systemtap installed, as well as the yum-utils, kernel-devel, kernel-headers, and kernel-debuginfo packages for your running kernel.

    # yum install -y yum-utils kernel-{devel,headers,debuginfo}-$(uname -r) systemtap && debuginfo-install -y kernel
    # yum install rpm-deathwatch
    
  • Note If you are using local repositories, you will need to sync the rhel-*-server-debug-rpms repository or the rpms can be manually downloaded from the Package Search

Starting the service

Notes

  • The first time rpm-deathwatch is run, the systemtap module will take up to a few minutes to build the module.

  • If the system is going to reboot before the issue reoccurs, you may want to enable the service

  • The service must be started BEFORE the issue occurs in order to log the signals sent to rpm, yum or dnf.

RHEL 6

  • To start the service:

    # /etc/rc.d/init.d/rpm-deathwatch start
    Starting rpm-deathwatch
    
  • Afterwards, check the status of the service:

    # /etc/rc.d/init.d/rpm-deathwatch status 
    Service running as 15070
    
  • To enable it to start during the system startup:

    # chkconfig --add rpm-deathwatch
    # chkconfig rpm-deathwatch on
    

RHEL 7 and RHEL 8

  • To start the service:

    # systemctl start rpm-deathwatch
    
  • To start the service and enable it to start during the system startup:

    # systemctl enable --now rpm-deathwatch
    
  • Afterwards, check the status of the service:

    # systemctl status rpm-deathwatch
    ● rpm-deathwatch.service - Systemtap module to monitor for termination signals sent to processes accessing the RPM database
      Loaded: loaded (/usr/lib/systemd/system/rpm-deathwatch.service; enabled; vendor preset: disabled)
      Active: active (running) since Wed 2020-08-19 08:19:10 EDT; 4s ago
    Main PID: 17824 (rpm-deathwatch)
      CGroup: /system.slice/rpm-deathwatch.service
              ├─17824 /usr/bin/python2 /usr/bin/rpm-deathwatch --name /var/log/rpm-deathwatch
              └─17834 /usr/bin/stap --suppress-handler-errors -DMAXSTRINGLEN=4096 -p4 -mrpm_deathwatch rpm_deathwatch.stp
    
    Aug 19 08:19:10 r7 systemd[1]: Started Systemtap module to monitor for termination signals sent to processes accessing the RPM database.
    Aug 19 08:19:10 r7 rpm-deathwatch[17824]: INFO:rpm-deathwatch:Checking the environment
    Aug 19 08:19:11 r7 rpm-deathwatch[17824]: INFO:rpm-deathwatch:Building the systemtap module to report termination signals
    Aug 19 08:19:35 r7 rpm-deathwatch[17824]: INFO:rpm-deathwatch:Starting monitoring
    Aug 19 08:19:35 r7 rpm-deathwatch[17824]: INFO:rpm-deathwatch:        Opened: /var/log/rpm-deathwatch-08-19-2020-08:19:35
    Aug 19 08:19:35 r7 rpm-deathwatch[17824]: INFO:rpm-deathwatch:Writing output to <__main__.files instance at 0x7f70d4a5c560>
    Aug 19 08:19:35 r7 rpm-deathwatch[17824]: INFO:rpm-deathwatch:Monitoring 18147
    

Collecting the data

  • Once the issue occurs while the service is running, please attach rpm-deathwatch-$(date +%m-%d).tar.bz2, generated by the below command, to a new or existing Red Hat Support Case

    # tar cjf rpm-deathwatch-$(date +%m-%d).tar.bz2 /var/log/rpm-deathwatch*
    

Root Cause

  • If rpm, yum or dnf does not exit cleanly the lock files are left behind. The files (__db001__db005) are left behind in /var/lib/rpm. We can see the pid that left the files with:

    # db_stat -C l -h /var/lib/rpm
    
  • The problem tends to be that we have no logs or audit configure for what actually killed the process. The most common reason being an automation tool timed out and abruptly ends the process without letting rpm clear the lock files.

  • The issue can be temporarily resolved by stopping any processes using files under the /var/lib/rpm directory and removing these files, or by a reboot which removes these files as well.

    • Check processes that are using /var/lib/rpm:

      # fuser -v /var/lib/rpm
      
    • Stop any services or kill processes reported by fuser -v /var/lib/rpm.

    • Afterwards, clear the lock files:

      # rm /var/lib/rpm/__db*
      
  • Microsoft Defender for Endpoint on Linux (MDATP) is known to cause the issue:

    • Check if it is installed:

      # rpm -q mdatp
      mdatp-101.98.64-1.x86_64
      
  • If the issue is reoccurring that is when automation becomes the most likely cause.

Diagnostic Steps

Example Logs

  • We can see the «Code 0» means that the commands are completing succesfully. This means the rpm-deathwatch service was started while rpm was working, which is good. We need rpm-deathwatch to run before the issue so it can capture the SIGKILL.

    Thu Dec  3 23:56:57 2020 EST: kprocess.exit: rpm(pid:31155) - Code   0 - "rpm -qa"
    Thu Dec  3 23:56:58 2020 EST: kprocess.exit: yum(pid:31171) - Code   0 - "/usr/bin/python /usr/bin/yum -y update
    Thu Dec  3 23:56:59 2020 EST: kprocess.exit: yum(pid:31171) - Code   0 - "/usr/bin/python /usr/bin/yum -y update
    
  • Now we have a SIGKILL. We define the process killed (yum), the pid of yum (31171), output the Process tree of who sent it, and the command that was killed.

    Fri Dec  4 00:00:17 2020 EST: sig.send: SIGKILL was sent to yum (pid:31171) by uid:0 using signal_generate
    Fri Dec  4 00:00:17 2020 EST: sig.send: Process tree:
     ->systemd[1] - <None found>
      ->BESClient[3563] - <None found>
    Fri Dec  4 00:00:17 2020 EST: kprocess.exit: yum(pid:31171) - Code   9 - "/usr/bin/python /usr/bin/yum -y update
    
  • From this, we can determine that BESClient sent the SIGKILL which killed yum (pid 31171) which was running a «yum update»



  • Product(s)

  • Red Hat Enterprise Linux


  • Component

  • rpm
  • yum


  • Category

  • Troubleshoot


  • Tags

  • audit
  • rhel
  • rpm
  • yum

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

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

Problem

You can see «db3 error(-30974)» errors when you are interacting with package management yum or rpm operations:

rpmdb: Thread/process 277623/140429100390144 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.verbose.cli.yumcompletets:Yum Error: Error: rpmdb open failed

Symptom

Rpmdb errors are seen during package management installation. They are related to corrupted RPM database.

yum -y install DSM-MicrosoftWindows-7.4-20211108193921.noarch.rpm
error: rpmdb: BDB0113 Thread/process 24446/139984907597632 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

Cause

These errors mean that the RPM database is corrupted.

Resolving The Problem

Follow these steps to back up and rebuild the rpm database:

Disclaimer: The next steps are an advanced procedure for users. If you are uncomfortable with this change or need assistance with rebuilding the RPM database, contact QRadar Support.

  1. Create a folder named «backup» in the next path: 
    mkdir /var/lib/rpm/backup
  2. Copy the db files to the backup folder:
    cp -a /var/lib/rpm/__db* /var/lib/rpm/backup/
  3. Remove the db.* files:
    rm -f /var/lib/rpm/__db.[0-9][0-9]*
  4. Run rpm -qa in «silence mode»:
    rpm --quiet -qa
  5. Rebuild the db:
    rpm --rebuilddb
  6. Clean:
    yum clean all
  7. After you execute these steps, proceed with the installation of the RPM:
    yum -y <RPM>

    Note: Replacing <RPM> with the rpm name you are trying to install. 

Result

     RPM is successfully installed.

Document Location

Worldwide

[{«Type»:»MASTER»,»Line of Business»:{«code»:»LOB24″,»label»:»Security Software»},»Business Unit»:{«code»:»BU059″,»label»:»IBM Software w\/o TPS»},»Product»:{«code»:»SSBQAC»,»label»:»IBM Security QRadar SIEM»},»ARM Category»:[{«code»:»a8m0z000000cwsyAAA»,»label»:»Admin Tasks»}],»ARM Case Number»:»»,»Platform»:[{«code»:»PF016″,»label»:»Linux»}],»Version»:»All Versions»}]

Понравилась статья? Поделить с друзьями:
  • Ошибка неисправность подвески range rover sport
  • Ошибка невозможно запустить это приложение на вашем пк
  • Ошибка невозможно открыть страницу
  • Ошибка неисправность озу блока управления
  • Ошибка невозможно запустить менеджер браузеров