Here is the procedure I have used to fix yum when it hangs. Usually, I will find one or more of the following kinds of rpm processes “running”:

# ps -ef | grep rpm
root 27265 26840 0 Feb05 ? 00:00:00 awk -v progname=/etc/cron.daily/rpm progname {????? print progname “:\n”????? progname=””;???? }???? { print; }

The first thing I do is cancel or kill my yum processes. Then, I kill all the running rpm processes using the following:

# killall -9 -r “.*rpmq.*”

Next, I remove all the __ files in the /var/lib/rpm directory:

# cd /var/lib/rpm
# ls
Basenames __db.000 __db.002 Dirnames Group Name Providename Pubkeys Requireversion Sigmd5
Conflictname __db.001 __db.003 Filemd5s Installtid Packages Provideversion Requirename Sha1header Triggername
# rm _*
rm: remove regular empty file `__db.000′? y
rm: remove regular file `__db.001′? y
rm: remove regular file `__db.002′? y
rm: remove regular file `__db.003′? y

Then, rebuild the rpm database:

# rpm –rebuilddb

I usually clean out the yum cache files by running the following:

# yum clean all