YUM更新出错后的处理
今日使用 yum -y update 更新 剛安裝好的 Linux CentOS 5.1 系統時,但更新到一半忽然停電..
等來電時,再度使用 yum -y update 進行更新時,卻無法更新了,一直出現以下的錯誤:
#yum -y update
Loading "installonlyn" plugin
Setting up Update Process
Setting up repositories
Reading repository metadata in from local files
Traceback (most recent call last):
File "/usr/bin/yum", line 29, in ?
yummain.main(sys.argv[1:])
File "/usr/share/yum-cli/yummain.py", line 94, in main
result, resultmsgs = base.doCommands()
File "/usr/share/yum-cli/cli.py", line 381, in doCommands
return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)
File "/usr/share/yum-cli/yumcommands.py", line 150, in doCommand
return base.updatePkgs(extcmds)
File "/usr/share/yum-cli/cli.py", line 673, in updatePkgs
self.doRepoSetup()
File "/usr/share/yum-cli/cli.py", line 109, in doRepoSetup
self.doSackSetup(thisrepo=thisrepo)
File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 341, in doSackSetup
self.pkgSack.excludeArchs(archlist)
File "/usr/lib/python2.4/site-packages/yum/packageSack.py", line 331, in excludeArchs
sack.excludeArchs(archlist)
File "/usr/lib/python2.4/site-packages/yum/sqlitesack.py", line 589, in excludeArchs
obj = self.pc(rep,self.db2class(x))
File "/usr/lib/python2.4/site-packages/yum/sqlitesack.py", line 431, in db2class
y.checksum = {'pkgid': 'YES','type': db.checksum_type,
File "/usr/lib/python2.4/site-packages/sqlite/main.py", line 97, in __getattr__
raise AttributeError, key
AttributeError: CHECKSUM_VALUE
心想,真是糟糕了,這一下該如何是好...使用 yum clean all 也無法解決,經過百般的抽絲剝繭後終於搞定了
以下為解決的方式:
#rpm -qa | grep yum-metadata-parser
得到以下結果
yum-metadata-parser-1.1.2-2.el5
yum-metadata-parser-1.0-8.fc6
怪了怎麼會有兩個,肯定是斷電後所造成的安裝不完整,而該套件是造成上訴的問題,所以將這兩個套件給先移除
#rpm -ev --nodeps yum-metadata-parser-1.1.2-2.el5
#rpm -ev --nodeps yum-metadata-parser-1.0-8.fc6
移除後再將 yum-metadata-parser-1.1.2-2.el5 安裝回去 方法有二:
方法一:
#yum insatll yum-metadata-parser
(此時已經正常可以透過 yum 去安裝了,如果不行,請用方法二)
方法二:
#wget http://ftp.cse.yzu.edu.tw/pub/CentOS/5.2/os/i386/CentOS/yum-metadata-parser-1.1.2-2.el5.i386.rpm
#rpm -iv yum-metadata-parser-1.1.2-2.el5.i386.rpm
安裝好 yum-metadata-parser 後,再使用 yum -y update 去更新,已經可以正常了,不會再出現上述的問題了..