The Problem
Unable to execute any command related to yum and below error messages found in /var/log/messages file. For example:
# yum update
Loaded plugins: aliases, changelog, downloadonly, kabi, presto, refresh-packagekit, security, tmprepo, verify, versionlock
Loading support for kernel ABI
Setting up Install Process
Ol6_latest | 3.0 kB 00:00
Ol6_latest/primary_db | 78 MB 00:10
[Errno 2] No such file or directory: '/var/cache/yum/x86_64/6Server/Ol6_latest/primary.sqlite.bz2'
Loaded plugins: aliases, changelog, downloadonly, kabi, presto, refresh-packagekit, security, tmprepo, verify, versionlock
Loading support for kernel ABI
Setting up Update Process
Ol6_latest/primary_db | 78 MB 00:10
Resolving Dependencies
--> Running transaction check
---> Package expat.x86_64 0:2.0.1-11.el6_2 will be updated
Error: database disk image is malformed
The Solution
The common reason for this error is yum misconfiguration or yum related DB corruption. Follow the steps below in order to resolve the issue:
1. Check and delete any unwanted or wrongly configured files under the path /etc/yum.repos.d.
2. Run “yum clean all” command.
# yum clean all
3. Now try to perform “yum update”:
# yum update