yum 実行時のエラー「does not match checksum」の対処方法
yum を実行した場合に「[Errno -1] Metadata file does not match checksum」というエラーが発生しました。
その時の対処内容を備忘録として書きました。
「yum update」で「does not match checksum」「No more mirrors to try」が発生
通常通り「yum update」を実行したところ、以下の2つのエラーが発生しました。
- [Errno -1] Metadata file does not match checksum Trying other mirror.
- [Errno 256] No more mirrors to try.
実際のエラー
# yum update Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile 〜 省略 〜 http://www.ftp.ne.jp/Linux/packages/CentOS/5.5/updates/i386/repodata/primary.sqlite.bz2: [Errno -1] Metadata file does not match checksum Trying other mirror. Error: failure: repodata/primary.sqlite.bz2 from updates: [Errno 256] No more mirrors to try.
yumリポジトリのアクセス先を変更
なんとなく、yumリポジトリのあたりでエラーが発生しているっぽいので、STDMAN yumでエラーが発生してupdateできない を参考に、「/etc/yum.repos.d/CentOS-Base.repo」を変更してみます。
変更内容としては、「mirrorlist=http〜〜」をコメントアウトして、「#baseurl=http〜〜」のコメント解除をします。
対象ファイル | /etc/yum.repos.d/CentOS-Base.repo |
---|
変更箇所
# コメントアウト #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os # コメントアウトを解除 baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
上記の変更について、変更箇所が1箇所ではなく数カ所あるので、sed で一括で変換します。
CentOS-Base.repo を sed で一括変換
念のためバックアップを取っておく # cp -p /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.org 「mirrorlist=http〜〜」をコメントアウト # sed -i "s/^mirrorlist/#mirrorlist/g" /etc/yum.repos.d/CentOS-Base.repo 「#baseurl=http〜〜」のコメントアウトを解除 # sed -i "s/^#baseurl/baseurl/g" /etc/yum.repos.d/CentOS-Base.repo
もう一度 yum を実行
設定変更が終わったので、もう一度「yum update」を実行してみます。
一応「yum clean all」を実行しておく
yumでエラーが発生する要因として、yumデータベースが壊れているケースもあるので、「yum clean all」でデータベースをクリアしておきます。
# yum clean all Loaded plugins: fastestmirror Cleaning up Everything Cleaning up list of fastest mirrors
「yum update」を実行(成功!)
「yum clean all」が終わったら、もう一度「yum update」を実行してみます。
# yum update Loaded plugins: fastestmirror Determining fastest mirrors 〜 省略 〜 Complete!
今度は正常に完了しました。
お試しでyumでrubyをインストール
「yum update」が成功したので、お試しで yum から Ruby をインストールしてみます。
# yum install ruby Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Setting up Install Process 〜 省略 〜 Installed: ruby.i386 0:1.8.5-5.el5_4.8 Dependency Installed: ruby-libs.i386 0:1.8.5-5.el5_4.8 Complete! # # ruby -v ruby 1.8.5 (2006-08-25) [i386-linux]
これも正常にインストールが完了しました。
今回参考にしたページ
STDMAN yumでエラーが発生してupdateできない
http://stdman.blogspot.com/2008/06/yumupdate.html
yumによるパッケージ更新時にエラーが表示される − @IT
http://www.atmarkit.co.jp/flinux/rensai/linuxtips/909yumerror.html
sedでファイルを置換する - より良い環境を求めて
http://d.hatena.ne.jp/n314/20080606/1212733838