yumで「Metadata file does not match checksum Trying other mirror.」の場合はmetadataのキャッシュをクリアして解決しよう。




投稿日:

yum update やyum installを実行すると、yes or no と聞かれる前に、「Metadata file does not match checksum Trying other mirror.」というエラーが吐かれていくつものリポジトリをぐるぐる回っていく現象が起こる事があります。

これを解決するには、metadata のキャッシュを再構成することで直ります。

# yum clean metadata

また、yum clean allでも同様に、metadata含めてキャッシュを全て消してくれます。

# yum clean all

このどちらかのコマンド実行後、yum updateなどを実行すると、問題は解決されていると思います。

yum cleanはyumのキャッシュディレクトリの掃除をするコマンドです。
いくつか種類があります。manの内容はこちらです。

CLEAN OPTIONS
The following are the ways which you can invoke yum in clean mode. Note that “all files” in the commands below means “all files in currently enabled repositories”. If you want to also clean any (temporarily) disabled repositories you need to use –enablerepo=’*’ option.

yum clean expire-cache
Eliminate the local data saying when the metadata and mirrorlists were downloaded for each repo.This means yum will revalidate the cache for each repo. next time it is used. However if the cacheis still valid, nothing significant was deleted.

yum clean packages
Eliminate any cached packages from the system. Note that packages are not automatically deleted after they are downloaded.

yum clean headers
Eliminate all of the header files which yum uses for dependency resolution.

yum clean metadata
Eliminate all of the files which yum uses to determine the remote availability of packages. Using this option will force yum to download all the metadata the next time it is run.

yum clean dbcache
Eliminate the sqlite cache used for faster access to metadata. Using this option will force yum to recreate the cache the next time it is run.

yum clean all
Runs yum clean packages and yum clean headers, yum clean metadata and yum clean dbcache as above.

ちなみに、キャッシュの確認は以下のように可能です。

【確認】

$ du -h /var/cache/yum
4.0K	/var/cache/yum/extras/packages
2.0M	/var/cache/yum/extras
4.0K	/var/cache/yum/updates/packages
1.4M	/var/cache/yum/updates
4.0K	/var/cache/yum/base/packages
37M	/var/cache/yum/base
41M	/var/cache/yum

【キャッシュ削除】

yum clean all