Yum - Metadata file does not match checksum
During a yum operation the error 'Metadata file does not match checksum' is reported. This error occurs on CentOS, RHEL, Fedora etc.
This error is likely to be due to http caching, where the versions of the yum repository files are inconsistent. The yum repository has the following files:
- repomd.xml
- filelists.xml.gz
- other.xml.gz
- primary.xml.gz
The 'repomd.xml' file describes the other three files, and contains a hash.
It should be noted that a 'yum clean all' will not solve this issue, as the out of date cached files will be downloaded again.
An example error:
filelists.xml.gz 100% |=========================| 3.3 MB 00:00 http://fr2.rpmfind.net/linux/dag/redhat/el5/en/x86_64/rpmforge/repodata/filelists.xml.gz: [Errno -1] Metadata file does not match checksum Trying other mirror. filelists.xml.gz 100% |=========================| 3.3 MB 00:00 http://ftp-stud.fht-esslingen.de/dag/redhat/el5/en/x86_64/rpmforge/repodata/filelists.xml.gz: [Errno -1] Metadata file does not match checksum Trying other mirror. filelists.xml.gz 100% |=========================| 3.3 MB 00:00 http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/repodata/filelists.xml.gz: [Errno -1] Metadata file does not match checksum Trying other mirror. Error: failure: repodata/filelists.xml.gz from rpmforge: [Errno 256] No more mirrors to try.
Workarounds
Possible workarounds for how to overcome this are:
- Do nothing, and just wait for the http cache to time out
- Issue a 'wget' with a no cache directive, for every file that might be being cached
- Bypass the http cache
- Temporarily configure yum to not use cached versions of files
The first option to do nothing is only an option if you want to defer the work being performed. The second option seems to be the normal way. For each file issue a 'wget' with the no-cache option:
wget --no-cache http://....../repodata/repomd.xml wget --no-cache http://....../repodata/filelists.xml.gz wget --no-cache http://....../repodata/primary.xml.gz wget --no-cache http://....../repodata/other.xml.gz
The fourth option is to temporarily reconfigure yum. Edit /etc/yum.conf, and add the following line:
http_caching=none
By disabling the caching, yum will set the http header 'Pragma: no-cache' (Note: yum doesn't appear to use the http Cache-Control header).
Using the finer grain 'http_caching=packages' configuration option is likely to yield the same result, but for a short term fix, disabling all caching is a 'large hammer' approach.
I suspect that leaving this option on could significantly effect performance if the yum repositories are not close. Once yum has performed the operation required, comment out or remove the option. Leaving the option will mean the any intermediate caches won't be able to cache as effectively.
There doesn't appear to be a command line equivalent option for this configuration file option.
Syntax
The 'httpcaching' directive defaults to 'all' and can be set globally in '/etc/yum.conf'
http_caching = { all, none, packages }
The code yumRepo.py uses the http_caching flag to set the 'Pragma: no-cache' http header:
# We will always prefer to send no-cache.
if not (cache or self.http_headers.has_key('Pragma')):
headers.append(('Pragma', 'no-cache'))
Links
http://yum.baseurl.org/wiki/Faq
http://www.gnu.org/software/wget/
http://www.gnu.org/software/wget/manual/html_node/HTTP-Options.html#HTTP-Options