解決yum [Errno -1] Metadata file does not match checksum
?yum clean all
yum clean metadata
yum makecache --disableplugin=fastestmirror
升級(jí)os:
yum update
?
You can try doing?sudo yum clean all?or?sudo rm -rf?
/var/cache/yum.
Follow that with?yum check-update. You may still?
get those errors, if so, the
problem is on the other end, they have invalid?
or corrupted data and you'll have to wait
for your mirrors to resync with?
correct data.
If you don't want to wait, you can manually download the?
updates and use the
yum localinstall method.
? ?最近發(fā)現(xiàn),在使用yum更新包的時(shí)候,常報(bào)下面的錯(cuò)誤:
引用 Reading repository metadata in from local filesprimary.xml.gz ? ? ? ? ? ?100% |=========================| 1.7 MB ? ?02:25
http://www.mirrorservice.org/sites/apt.sw.be/redhat/el4/en/i386/dag/repodata/primary.xml.gz:?
[Errno -1]?Metadata file does not match checksum
Trying other mirror.
? ?有時(shí)候當(dāng)替換了幾個(gè)鏡像后就可以了。但經(jīng)常也會(huì)發(fā)現(xiàn)最終是失敗的。由于我的系統(tǒng)是依賴yum更新的,若使用國(guó)外網(wǎng)絡(luò)源的時(shí)候出這樣的問題,影響挺大的。
? ?Google搜索了一下,是一個(gè)常見問題,也提供了一些方法。只是后來發(fā)現(xiàn),這些方法要不就是沒有說清楚,要不就是誤解。經(jīng)過測(cè)試,最終基本可以解決了。
一、原因
從該地址找到一段說明:點(diǎn)擊
Now, think of this: download.fedora.redhat.com updates their metadata and checksums, so you're getting the new checksum. The mirror's cronjobs havn't gone yet, therefore no synching and the metadata isn't the newest, it doesn't match.
The solution is not to makecache; Although it may help it will take forever and still not 100% solve the problem. The main problem is not giving the mirrors enough synch time. Typically, cron runs every hour, and give it a bit of time to download the changes, so I'd say try running maybe 10 minutes after an hour and you'll have no problem (eg 3:10, 4:10, 5:10, etc...). If you get closer to :50 (3:50, :50, etc) you'll start seeing more syncing issues.
Again, this too isn't 100% perfect but more of a guideline. There's a lot of guesswork...
大概的意思是說:
文中提供的解決方法是,根據(jù)大部分的鏡像都是每小時(shí)進(jìn)行一次數(shù)據(jù)同步或生成校驗(yàn)數(shù)據(jù)的,所以,不要選擇接近整點(diǎn)的時(shí)候更新數(shù)據(jù),而應(yīng)選擇整點(diǎn)過后再更新。但這只是建議,不能保證一定能解決該問題。
參考該文章的內(nèi)容,我們可以看看yum更新下載的數(shù)據(jù): /var/cache/yum,根據(jù)你定義的repo.d文件內(nèi)容,會(huì)分開多層目錄,每層代表一個(gè)更新路徑。
其中,primary.xml.gz、filelists.xml.gz、和other.xml.gz就是metadata信息,而repomd.xml就是校驗(yàn)數(shù)據(jù)。其使用的是sha1進(jìn)行校驗(yàn)的。
找到原因,解決就不難了。
二、解決
1、清空緩存
執(zhí)行:
先把就的緩存數(shù)據(jù)都去掉。
2、下載metadata和校驗(yàn)數(shù)據(jù)
先進(jìn)入yum對(duì)應(yīng)的目錄,再下載:
# wget --cache=off http://apt.sw.be/redhat/el4/en/i386/dag/repodata/repomd.xml
# wget --cache=off http://apt.sw.be/redhat/el4/en/i386/dag/repodata/primary.xml.gz
# wget --cache=off http://apt.sw.be/redhat/el4/en/i386/dag/repodata/filelists.xml.gz
# wget --cache=off http://apt.sw.be/redhat/el4/en/i386/dag/repodata/other.xml.gz
3、校驗(yàn)數(shù)據(jù)
執(zhí)行:
74fcc9f9e218cfdbc1ac2b5ac17ff7d912267bdf ?other.xml.gz
3f4b2e9a5efc67c0cdf329c69f041daa82a2346c ?filelists.xml.gz
bd2033e1fd7a7d1f1b92ce7b880919bd685217f8 ?primary.xml.gz
對(duì)比repomd.xml中的信息:
? ?<checksum type="sha">74fcc9f9e218cfdbc1ac2b5ac17ff7d912267bdf</checksum>
? ?<checksum type="sha">3f4b2e9a5efc67c0cdf329c69f041daa82a2346c</checksum>
? ?<checksum type="sha">bd2033e1fd7a7d1f1b92ce7b880919bd685217f8</checksum>
若數(shù)據(jù)正確,則說明metadata和校驗(yàn)數(shù)據(jù)是匹配的。可以使用yum更新了,不會(huì)再重新下載metadata。
否則,可以再等待一下,或需要從其他的鏡像獲取更新咯。
三、建議
因?yàn)槲覀儾荒芸刂歧R像更新的速度和時(shí)間,而我們的工作只是避免了yum可能發(fā)生誤判的情況,但并不能完全保證上面的工作是成功的。
從盡可能避免該問題的角度出發(fā),有幾個(gè)建議:
1、選擇好的鏡像
設(shè)置yum.repos.d中baseurl或mirrorlist從好的鏡像下載。若知道某個(gè)鏡像速度快,則干脆用baseurl固定,而不要使用mirrorlist了。
2、排查網(wǎng)絡(luò)問題
網(wǎng)上提供的方法大部分是轉(zhuǎn)載這里的。其建議使用--cache=off參數(shù)(表示不使用服務(wù)器中的高速緩存中的數(shù)據(jù))。
但實(shí)際上,我發(fā)現(xiàn)除非網(wǎng)絡(luò)有問題,否則是否使用該參數(shù)拿回來的數(shù)據(jù)不應(yīng)該有有區(qū)別的。
如:
bd2033e1fd7a7d1f1b92ce7b880919bd685217f8 ?primary.xml.gz
bd2033e1fd7a7d1f1b92ce7b880919bd685217f8 ?primary.xml.gz.1
※primary.xml.gz是使用--cache=off參數(shù)的,而primary.xml.gz.1是沒有使用該參數(shù)的。
所以,如果網(wǎng)絡(luò)出現(xiàn)問題,是會(huì)影響到y(tǒng)um下載數(shù)據(jù)的完整性的。而使用--cache=off既然沒壞,不妨使用咯。
四、參考資料
http://lists.freshrpms.net/pipermail/freshrpms-list/2005-May/013037.html
http://lists.freshrpms.net/pipermail/freshrpms-list/2004-November/011553.html
http://www.fedorachina.cn/index.php?topic=26.0
http://www.linuxsir.org/bbs/printthread.php?t=316600
轉(zhuǎn)載于:https://blog.51cto.com/2816056/1167211
總結(jié)
以上是生活随笔為你收集整理的解決yum [Errno -1] Metadata file does not match checksum的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Epicor 安装Enterprise
- 下一篇: win10最新进不了系统更新不了怎么办