What do do when Yum hangs or freezes
1) Check for any processes holding the rpm database open using command
lsof | grep /var/lib/rpm
If this gives any output, kill all processes using kill -9 PID
2) Delete temporary DB files
rm -f /var/lib/rpm/__*
3) Next is to rebuild RPM database
rpm --rebuilddb -v -v
This usually does the trick.
Other causes may be yum repositories /etc/yum.repos.d/*.repo that are not accessible from your server. iptables rules which prevents you from connecting to yum repositories may be another cause.