环境说明

[root@thatsit ~]# cat  /etc/redhat-release
CentOS Linux release 7.1. (Core)
[root@thatsit ~]# uname -r
3.10.-229.7..el7.x86_64
[root@thatsit ~]#

报错信息

[root@thatsit ~]# yum  -y install  docker
error: rpmdb: BDB0113 Thread/process / failed: BDB1507 Thread died in Berkeley DB library
error: db5 error(-) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db5 - (-)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main: Error: rpmdb open failed
[root@thatsit ~]#

处理步骤

1, rm -f /var/lib/rpm/__db*    # 删除/var/lib/rpm 目录下的__db开头的rpmdb文件
2, rpm --rebuilddb # rpm数据库重建
3, yum clean all # 清理所有yum缓存
4, yum makecache # 重新生成yum缓存

※: 此解决法方法在RHEL/CentOS 5
(未测试),6,7系列的操作系统中都是适用的.

执行过程

[root@thatsit ~]# cd  /var/lib/rpm
[root@thatsit rpm]# ll -htr
total 42M
-rw-r--r--. root root .0K Feb : Triggername
-rw-r--r--. root root 16K Feb : Obsoletename
-rw-r--r--. root root .0K Feb : Conflictname
-rw-r--r--. root root 32K Feb : Name
-rw-r--r--. root root 2.4M Feb : Basenames
-rw-r--r--. root root 16K Feb : Group
-rw-r--r--. root root 200K Feb : Requirename
-rw-r--r--. root root 1.5M Feb : Providename
-rw-r--r--. root root 1.1M Feb : Dirnames
-rw-r--r--. root root 12K Feb : Installtid
-rw-r--r--. root root 40K Feb : Sigmd5
-rw-r--r--. root root 52K Feb : Sha1header
-rw-r--r--. root root 35M Feb : Packages
-rw-r--r-- root root 1.3M Feb : __db.
-rw-r--r-- root root 104K Feb : __db.
-rw-r--r-- root root 432K Feb : __db.
[root@thatsit rpm]# rm -f __db*
[root@thatsit rpm]# rpm --rebuilddb
[root@thatsit rpm]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base epel extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@thatsit rpm]# yum makecache
Loaded plugins: fastestmirror
base | 3.6 kB ::
epel/x86_64/metalink | 5.7 kB ::
epel | 4.3 kB ::
extras | 3.4 kB ::
updates | 3.4 kB ::
(/): base//x86_64/group_gz | kB ::
(/): base//x86_64/primary_db | 5.3 MB ::
(/): epel/x86_64/group_gz | kB ::
(/): base//x86_64/filelists_db | 6.2 MB ::
(/): extras//x86_64/filelists_db | kB ::
(/): extras//x86_64/prestodelta | kB ::
(/): extras//x86_64/primary_db | kB ::
(/): epel/x86_64/other_db | 1.8 MB ::
(/): epel/x86_64/primary_db | 3.9 MB ::
(/): base//x86_64/other_db | 2.3 MB ::
(/): extras//x86_64/other_db | kB ::
(/): updates//x86_64/prestodelta | kB ::
(/): updates//x86_64/filelists_db | 1.9 MB ::
(/): epel/x86_64/updateinfo | kB ::
(/): updates//x86_64/primary_db | 3.1 MB ::
(/): epel/x86_64/filelists_db | 6.4 MB ::
(/): updates//x86_64/other_db | MB ::
Determining fastest mirrors
* base: mirrors.aliyun.com
* epel: mirrors.yun-idc.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Metadata Cache Created
[root@thatsit rpm]#

故障原因:

(原文地址: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 is a Berkeley DB key-value store, and very sensitive. When such a crash happens, the rpmdb is 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.

Two notable bugs you may have seen on older CentOS systems can cause this. The big one, a "nasty and subtle race in shared 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 report, though.

The one you might see from 2009 happened when PackageKit would kill yum at an inopportune time, and was also fixed. This would be more likely to affect desktop systems or servers with a GUI, though.

All of these bugs predate EL 6, and you should almost never see this occur on EL 6 or 7, nor should you see it if your EL 5 systems are up to date. (I have no idea about EL 4. If you have one, kill it before it spreads.) That said, anything that causes yum or rpm to die while working with the rpmdb could cause it. This includes what 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 inhibited). This should help prevent most situations in which someone or something interrupts the transaction and causes this problem.

更多关于yum的故障处理

请移步:http://xmodulo.com/how-to-fix-yum-errors-on-centos-rhel-or-fedora.html

文中涉及的错误类型包括下面7中:

1. Fix 404 Errors
2. Fix Connection Failure Errors
3. Fix Metadata Checksum Errors
4. Fix Yum Lock Errors
5. Fix Repository Database Read Errors
6. Fix Repository Metadata Read Errors
7. Fix Packages Database Error

CentOS yum Fatal Error 处理一例的更多相关文章

  1. Yum出错Error: Cannot find a valid baseurl for repo: base(转)

    centos yum 错误 Error: Cannot find a valid baseurl for repo: base 装了个CentOS 6.x,使用yum时出现了下面的错误提示.Loade ...

  2. Yum出错Error: Cannot find a valid baseurl for repo: base

    centos yum 错误 Error: Cannot find a valid baseurl for repo: addons 装了个CentOS 6.5,使用yum时出现了以下的错误提示. [r ...

  3. centos 7安装mysql 执行./scripts/mysql_install_db --user=mysql 报错 FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db: Data::Dumper

    [root@localhost mysql]# ./scripts/mysql_install_db  --user=mysql FATAL ERROR: please install the fol ...

  4. yum 安装报错:Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

    [root@venn09 ~]# yum install -y vim Loaded plugins: fastestmirror Could not retrieve mirrorlist http ...

  5. Centos 7.5源码编译安装zabbix4.0报fatal error: mysql.h: No such file or directory

    系统环境:CentOS 7.5是最小化安装的 编译信息 编译选项: root@Server01 zabbix-]# ./configure --prefix=/usr/share/applicatio ...

  6. 转载: LINK : fatal error LNK1104: 无法打开文件“mfc71.lib”的原因又一例

    转载地址:http://blog.csdn.net/mxclxp/article/details/8196142 LINK : fatal error LNK1104: 无法打开文件“mfc71.li ...

  7. php提示Fatal error: Call to undefined function imagecreate()

    在php中imagecreate函数是一个图形处理函数,主要用于新建一个基于调色板的图像了,然后在这个基础上我们可以创建一些图形数字字符之类的,但这个函数需要GD库支持,如果没有开启GD库使用时会 / ...

  8. lua.c:80:31: fatal error: readline/readline.h: No such file or directory

    make linuxcd src && make linuxmake[1]: Entering directory `/root/lua/lua-5.3.2/src'make all ...

  9. fatal error: openssl/evp.h: 没有那个文件或目录

    在陆佳华<嵌入式系统软硬件协同设计实战指南 第2版>一书的第13章节 编译U-boot时会遇到2个错误.原因很简单,就从一开始的错误提示着手: fatal error: openssl/e ...

随机推荐

  1. 您为这个网络适配器输入的IP地址xxx.xxx.xxx.xx已经分配给另一个适配器xxx...

    您为这个网络适配器输入的IP地址xxx.xxx.xxx.xx已经分配给另一个适配器‘xxx NIC’.... 2008年11月03日 星期一 08:51 问题现象:   在网卡的TCP/IP属性中无法 ...

  2. Ehcache入门(一)——开发环境的搭建

    EhCache 是一个纯Java的进程内缓存框架,具有快速.精干等特点,是Hibernate中默认的CacheProvider. 那么.如何搭建Ehcache的开发环境呢? 1.下载相关的jar包,这 ...

  3. bootstrap兼容IE8的一些注意

    准备 bootstrap 3.3.5 jQuery 1.12.0 注意 支持html5 需要引入html5.js 支持placeholder 需要引入placeholder.js ie8 不支持 fo ...

  4. 你好,C++(17)0.1*10不等于1.0——4.1.4 关系操作符4.1.5 逻辑操作符

    4.1.4  关系操作符 在C++中,除了需要用算术操作符对数据进行加减乘除的算术操作之外,我们有时候还需要对数据之间的关系进行操作,也就是对两个数据进行大小比较,得出它们之间的大小关系.在现实世界中 ...

  5. cookie,localStorage,sessionStorage

    1.cookie 由于HTTP是一种无状态的协议,服务器单从请求内容上无法判断客户身份.因此,cookie弥补这个缺陷,每次请求都携带cookie,这样服务器就能能知道不同的客户端请求了. 对于同一域 ...

  6. 求奇数的乘积 AC 杭电

    求奇数的乘积 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub ...

  7. DEVICE_OBJECT结构参数

    typedef struct DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) _DEVICE_OBJECT { CSHORT Type; USHORT Size ...

  8. LeetCode_Single Number II

    Given an array of integers, every element appears three times except for one. Find that single one. ...

  9. Local System/Network Service/Local Service

    // The name of the account under which the service should run// 1 NT AUTHORITY\\SYSTEM 2 NT AUTHORIT ...

  10. eclipse中格式化代码快捷键Ctrl+Shift+F失效的解决办法

    很长一段时间我的eclipse都有个毛病,就是当我要格式化代码的时候,右键-source-format能够起效,但ctrl+shift+f不好使了. 可以基本断定是快捷键与别的软件冲突了,但一直也没时 ...