Environment description
Cat /etc/redhat-7.1. 1503 uname -R3.10. 0-229.7. 2 ~]#
Error message
[Email protected] ~]#Yum-YInstallDocker error:rpmdb:BDB0113 Thread/process38301/139855495489536failed:bdb1507 Thread diedinchBerkeley DB LIBRARYERROR:DB5 error (-30973) from dbenv->failchk:bdb0087 db_runrecovery:fatal error, run database Recoveryerror:cannot open Packages index using DB5- (-30973) Error:cannot Open Packages databaseinch/var/lib/rpmcritical:Yum. Main:Error:rpmdb open Failed[[email protected]~]#
Process steps
1, rm-f/var/lib/rpm/__db* # Delete rpmdb file at the beginning of __db/var/lib/rpm directory 2, rpm--rebuilddb # RPM Database rebuild 3, yum clean all # Clean up all Yum cache 4, yum Makecache # regenerate Yum cache
※: This workaround methodis applicable in Rhel/centos 5 (not tested) and in the6,7 series of operating systems.
Execution process
[Email protected] ~]# cd/var/lib/Rpm[[email protected] rpm]# ll-htrtotal 42M-rw-r--r--.1Root root8.0K Feb - -: totriggername-rw-r--r--.1Root root 16K Feb - -: toObsoletename-rw-r--r--.1Root root8.0K Feb - -: toConflictname-rw-r--r--.1Root root 32K Feb - -: toName-rw-r--r--.1Root root2.4MFeb - -: toBasenames-rw-r--r--.1Root root 16K Feb - -: toGroup-rw-r--r--.1Root root 200K Feb - -: toRequirename-rw-r--r--.1Root root1.5MFeb - -: toProvidename-rw-r--r--.1Root root1.1MFeb - -: toDirnames-rw-r--r--.1Root root 12K Feb - -: toInstalltid-rw-r--r--.1Root root 40K Feb - -: toSIGMD5-rw-r--r--.1Root root 52K Feb - -: toSha1header-rw-r--r--.1Root root 35M Feb - -: $Packages-rw-r--r--1Root root1.3MFeb - A: -__db.003-rw-r--r--1Root root 104K Feb - A: -__db.002-rw-r--r--1Root root 432K Feb - A: -__db.001[email protected] rpm]#RM-F __db*[email protected] rpm]# rpm--Rebuilddb[[email protected] rpm]#YumClean allloaded plugins:fastestmirrorcleaning repos:base epel Extras updatescleaning up everythingcleaning up list of fastest Mirrors[[email protected] rpm]#Yummakecacheloaded plugins:fastestmirrorbase|3.6Kbxx:xx:xxEpel/x86_64/metalink |5.7Kbxx:xx:xxEpel|4.3Kbxx:xx:xxExtras|3.4Kbxx:xx:xxUpdates|3.4Kbxx:xx:xx (1/ -): base/7/x86_64/group_gz |155Kbxx:xx:xx (2/ -): base/7/x86_64/primary_db |5.3MBxx:xx: to (3/ -): Epel/x86_64/group_gz |169Kbxx:xx:xx (4/ -): base/7/x86_64/filelists_db |6.2MBxx:xx: . (5/ -): extras/7/x86_64/filelists_db |246Kbxx:xx:xx (6/ -): extras/7/x86_64/prestodelta | -Kbxx:xx:xx (7/ -): extras/7/x86_64/primary_db | -Kbxx:xx:xx (8/ -): epel/x86_64/other_db |1.8MBxx:xx: on (9/ -): epel/x86_64/primary_db |3.9MBxx:xx: on (Ten/ -): base/7/x86_64/other_db |2.3MBxx:xx: Geneva ( One/ -): extras/7/x86_64/other_db | theKbxx:xx:xx ( A/ -): updates/7/x86_64/prestodelta |239Kbxx:xx:xx ( -/ -): updates/7/x86_64/filelists_db |1.9MBxx:xx: on ( -/ -): Epel/x86_64/updateinfo |488Kbxx:xx:xx ( the/ -): updates/7/x86_64/primary_db |3.1MBxx:xx:Geneva ( -/ -): epel/x86_64/filelists_db |6.4MBxx:xx:Geneva ( -/ -): updates/7/x86_64/other_db | -MBxx:xx: -Determining fastest Mirrors*base:mirrors.aliyun.com* epel:mirrors.yun-idc.com*extras:mirrors.aliyun.com*updates:mirrors.aliyun.comMetadata Cache created[[email protected] rpm]#
Cause of failure:
(Original address: http://serverfault.com/questions/616666/why-does-yum-index-get-corrupted)
In the general case, this happens when rpm (or yum) crashes when updating the Rpmdb, which-a Berkeley DB key-value stor E, and very sensitive. When such a crash happens, the Rpmdb was left in an inconsistent state and this error occurs. All of the other files in/var/lib/rpm contain the same information, though in a less efficient format, so the database is Easily rebuilt. The bugs of the notable seen on older CentOS systems can cause. The big one, a "nasty and subtle race in Gkfx mmap ' Ed page writeback" as it appears in the Changelog, was quietly fixed In a kernel update in 2007. This one presented itself slightly differently than your, though. The one you might see from happened when PackageKit would kill Yum at a inopportune time, and was also fixed. This would is more likely to affect desktop systems or servers with a GUI, though. All of the These bugs predate El 6, and you should almost never see this occur on EL 6 or 7, nor should do see it if your EL 5 SysteMS is up to date. (I have no idea about EL 4.) If you have one, kill it before it spreads.) That's said, anything that causes yum or RPM-die while working with the rpmdb could cause it. This includes what do you ' re most likely to see these days, random cosmic rays flipping bits, or someone getting overzealous With kill-9.in RHEL 7, Yum traps more signals during the actual transaction run, and you'll see the message (Shutdown INH ibited). This should help prevent most situations in which someone or something interrupts the transaction and causes this problem.
More about Yum's fault handling
Please visit: http://xmodulo.com/how-to-fix-yum-errors-on-centos-rhel-or-fedora.html
The types of errors involved in this article include the following 7:1. Fix 404 Errors2. Fix Connection Failure Errors3. Fix Metadata Checksum Errors4. Fix Yum Lock Errors5. Fix Repository Database Read Errors6. Fix Repository Metadata Read Errors7. Fix Packages Database Error
A case of CentOS Yum Fatal Error handling