Skip to content Skip to main navigation Skip to footer

centos如何解决“rpmdb:PANIC: fatal region error detected; run recovery error and solution"错误

在centos 或者rhel系统,当你使用yum命令的时候可能会遇到下面的错误信息:

rpmdb: PANIC: fatal region error detected; run recovery
error: db3 error(-30974) from dbenv->open: 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.main:
Error: rpmdb open failed
 

如何解决这个问题呢?
首先要先备份下rpm数据库,以防万一。使用下面的命令备份rpm数据库:

cp -avr /var/lib/rpm/ /root/backups.rpm.mm_dd_yyyy/
 

显示所有的rpm 数据库文件,输入下面的命令:

ls -l /var/lib/rpm/_*
 

命令输出:

[root@devops Desktop]# ls -l /var/lib/rpm/_*
-rw-r--r--. 1 root root   24576 Dec 14 04:13 /var/lib/rpm/__db.001
-rw-r--r--. 1 root root  229376 Dec 14 04:13 /var/lib/rpm/__db.002
-rw-r--r--. 1 root root 1318912 Dec 14 04:13 /var/lib/rpm/__db.003
-rw-r--r--. 1 root root  753664 Dec 14 04:13 /var/lib/rpm/__db.004
 

执行下面的命令,修复问题:

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

到此我们可以执行一个yum命令来验证问题已经被解决。
输入下面命令:

yum repolist
 

命令输出:

[root@devops Desktop]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.btte.net
 * updates: mirrors.btte.net
repo id                        repo name                                  status
base                           CentOS-6 - Base                            6,518
extras                         CentOS-6 - Extras                             36
updates                        CentOS-6 - Updates                           494
repolist: 7,048
 
0 Comments

There are no comments yet

Leave a comment

Your email address will not be published.