1.下载yum指令包:
去163源目录中()下载下列yum指令包:
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpmwget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpmwget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpmwget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
2.安装yum指令包:
使用rpm -ivh安装进度显示来安装以上rpm包:
rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpmrpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
后两项须同时安装否则会互相依赖:
rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpmPreparing... ########################################### [100%] 1:yum-plugin-fastestmirro########################################### [ 50%] 2:yum ########################################### [100%]
3.替换自身源:
进入目录:
cd /etc/yum.repos.dmv CentOS-Base.repo CentOS-Base.repo-bak
在该目录下下载阿里yum源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
4. 清理并重建缓存
yum clean allyum makecache
报错信息:
Traceback (most recent call last): File "/usr/bin/yum", line 29, inyummain.user_main(sys.argv[1:], exit_code=True) File "/usr/share/yum-cli/yummain.py", line 298, in user_main errcode = main(args) File "/usr/share/yum-cli/yummain.py", line 187, in main (result, resultmsgs) = base.buildTransaction() File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 1003, in buildTransaction (rescode, restring) = self.resolveDeps() File "/usr/lib/python2.6/site-packages/yum/depsolve.py", line 781, in resolveDeps for po, dep in self._checkFileRequires(): File "/usr/lib/python2.6/site-packages/yum/depsolve.py", line 1066, in _checkFileRequires self.installedFileProviders = self.rpmdb.fileRequiresData() File "/usr/lib/python2.6/site-packages/yum/rpmsack.py", line 910, in fileRequiresData rpmdbv = self.simpleVersion(main_only=True)[0] File "/usr/lib/python2.6/site-packages/yum/rpmsack.py", line 1141, in simpleVersion if 'checksum_type' in ydbi and 'checksum_data' in ydbi: File "/usr/lib/python2.6/site-packages/yum/rpmsack.py", line 1870, in __contains__ x = self.get(attr) File "/usr/lib/python2.6/site-packages/yum/rpmsack.py", line 1900, in get res = self._read(attr) File "/usr/lib/python2.6/site-packages/yum/rpmsack.py", line 1817, in _read info = misc.stat_f(fn) File "/usr/lib/python2.6/site-packages/yum/misc.py", line 920, in stat_f return os.stat(filename)OSError: [Errno 5] 输入/输出错误: '/var/lib/yum/yumdb/a/f6c47592fc6a105295afe1701509e359802ea041-avahi-glib-0.6.25-15.el6-x86_64/checksum_data'
解决方法:
我将/var/lib/yum/yumdb 文件挪走后,yum 恢复正常