不知道有沒有跟我一樣的小伙伴,在使用yum安裝軟件時,發現無法正常使用yum安裝軟件包,下面出現幾句英語提示。在使用rpm時也無法正常的使用。其實 是rpm數據庫崩潰導致的 下面就簡單的介紹一下怎么回復,讓其正常的工作,很簡單幾個命了即可。
1. 出現錯誤提示,這時我們需要認真的閱讀下面的提示,不要亂找原因
[root@centos7 yum.repos.d]# vim YUM.repo
[root@centos7 yum.repos.d]# yum repolist
error: rpmdb: BDB0113 Thread/process 6396/140171373643584 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
2.跟著提示cd /var/lib/rpm 下 查看文件 刪除_db.* 所有文件
[root@centos7 yum.repos.d]# cd /var/lib/rpm
[root@centos7 rpm]# ls
Basenames __db.001 __db.003 Group Name Packages Requirename Sigmd5
Conflictname __db.002 Dirnames Installtid Obsoletename Providename Sha1header Triggername
[root@centos7 rpm]# rm _db.* -rf
3.刪除后 用rpm –rebuilddb 進行數據文件回復
[root@centos7 rpm]# rpm –rebuilddb
[root@centos7 rpm]# ls
Basenames Dirnames Installtid Obsoletename Providename Sha1header Triggername
Conflictname Group Name Packages Requirename Sigmd5
4.用yum update 更新數據即可
[root@centos7 rpm]# yum update
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00:00
Loading mirror speeds from cached hostfile
Resolving Dependencies
–> Running transaction check
—> Package httpd.x86_64 0:2.4.6-40.el7.centos will be updated
—> Package httpd.x86_64 0:2.4.6-45.el7.centos will be an update
—> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos will be updated
—> Package httpd-tools.x86_64 0:2.4.6-45.el7.centos will be an update
—> Package lftp.x86_64 0:4.4.8-7.el7 will be updated
—> Package lftp.x86_64 0:4.4.8-8.el7 will be an update
—> Package telnet.x86_64 1:0.17-59.el7 will be updated
—> Package telnet.x86_64 1:0.17-60.el7 will be an update
–> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================
Package Arch Version Repository Size
===================================================================================================
Updating:
httpd x86_64 2.4.6-45.el7.centos base 2.7 M
httpd-tools x86_64 2.4.6-45.el7.centos base 84 k
lftp x86_64 4.4.8-8.el7 base 751 k
telnet x86_64 1:0.17-60.el7 base 63 k
Transaction Summary
===================================================================================================
Upgrade 4 Packages
Total download size: 3.6 M
Is this ok [y/d/N]: y
Downloading packages:
—————————————————————————————————
Total 20 MB/s | 3.6 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : httpd-tools-2.4.6-45.el7.centos.x86_64 1/8
Updating : httpd-2.4.6-45.el7.centos.x86_64 2/8
Updating : lftp-4.4.8-8.el7.x86_64 3/8
Updating : 1:telnet-0.17-60.el7.x86_64 4/8
Cleanup : httpd-2.4.6-40.el7.centos.x86_64 5/8
Cleanup : httpd-tools-2.4.6-40.el7.centos.x86_64 6/8
Cleanup : lftp-4.4.8-7.el7.x86_64 7/8
Cleanup : 1:telnet-0.17-59.el7.x86_64 8/8
Verifying : 1:telnet-0.17-60.el7.x86_64 1/8
Verifying : httpd-tools-2.4.6-45.el7.centos.x86_64 2/8
Verifying : httpd-2.4.6-45.el7.centos.x86_64 3/8
Verifying : lftp-4.4.8-8.el7.x86_64 4/8
Verifying : httpd-2.4.6-40.el7.centos.x86_64 5/8
Verifying : httpd-tools-2.4.6-40.el7.centos.x86_64 6/8
Verifying : 1:telnet-0.17-59.el7.x86_64 7/8
Verifying : lftp-4.4.8-7.el7.x86_64 8/8
Updated:
httpd.x86_64 0:2.4.6-45.el7.centos httpd-tools.x86_64 0:2.4.6-45.el7.centos
lftp.x86_64 0:4.4.8-8.el7 telnet.x86_64 1:0.17-60.el7
Complete!
5.rpm和yum 恢復正常使用
[root@centos7 rpm]# rpm -q ntp
ntp-4.2.6p5-25.el7.centos.x86_64
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base
Cleaning up everything
Cleaning up list of fastest mirrors
原創文章,作者:huchaowei,如若轉載,請注明出處:http://www.www58058.com/78003