在CentOS 7系统上,在使用yum命令安装软件包时候报错
[root@VM-17-4-centos ~]# yum install tree -y error: rpmdb: BDB0113 Thread/process 18014/140179674609728 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:
从报错信息看,原因是RPM数据库被破坏
解决方案
[root@VM-17-4-centos filecmp_tmp]# ll /var/lib/rpm/ total 75328 -rw-r--r--. 1 root root 2658304 Jul 23 2020 Basenames -rw-r--r--. 1 root root 8192 Dec 30 2019 Conflictname -rw-r--r-- 1 root root 270336 Mar 5 10:54 __db.001 -rw-r--r-- 1 root root 81920 Mar 5 10:54 __db.002 -rw-r--r-- 1 root root 1318912 Mar 5 10:54 __db.003 -rw-r--r--. 1 root root 1253376 Jul 23 2020 Dirnames -rw-r--r--. 1 root root 24576 Jul 23 2020 Group -rw-r--r--. 1 root root 12288 Jul 23 2020 Installtid -rw-r--r--. 1 root root 45056 Jul 23 2020 Name -rw-r--r--. 1 root root 16384 Dec 27 2019 Obsoletename -rw-r--r--. 1 root root 69341184 Jul 23 2020 Packages -rw-r--r--. 1 root root 1863680 Jul 23 2020 Providename -rw-r--r--. 1 root root 237568 Jul 23 2020 Requirename -rw-r--r--. 1 root root 69632 Jul 23 2020 Sha1header -rw-r--r--. 1 root root 40960 Jul 23 2020 Sigmd5 -rw-r--r--. 1 root root 8192 Dec 23 2019 Triggername [root@VM-17-4-centos filecmp_tmp]# cd /var/lib/rpm/;for i in `ls | grep 'db.'`;do mv $i $i.bak;done [root@VM-17-4-centos rpm]# rpm --rebuilddb [root@VM-17-4-centos rpm]# yum clean all Loaded plugins: fastestmirror, langpacks Repository epel is listed more than once in the configuration Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast Cleaning repos: epel extras os updates webtatic 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
然后重新使用yum进行安装就没有问题了