1.备份或删除yum源配置文件
[root@rh5 yum.repos.d]# ll
total 24
-rw-r--r-- 1 root root 300 Jun 29 16:34 bendi.repobak
-rw-r--r-- 1 root root 190 Jun 29 16:34 redhat.repobak
-rw-r--r-- 1 root root 254 Jan 24 2012 rhel-debuginfo.repobak
[root@rh5 yum.repos.d]#
2.编辑vi/etc/yum.repos.d/CentOS-Base.repo,填入以下内容
[root@rh5 yum.repos.d]# catCentOS-Base.repo
[base]
name=CentOS-5 - Base
repo=os
baseurl=http://centos.ustc.edu.cn/centos/5/os/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
[update]
name=CentOS-5 - Updates
baseurl=http://centos.ustc.edu.cn/centos/5/updates/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
[addons]
name=CentOS-5 - Addons
baseurl=http://centos.ustc.edu.cn/centos/5/addons/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
[extras]
name=CentOS-5 - Extras
baseurl=http://centos.ustc.edu.cn/centos/5/extras/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
[centosplus]
name=CentOS-5 - Plus
baseurl=http://centos.ustc.edu.cn/centos/5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
[contrib]
name=CentOS-5 - Contrib
baseurl=http://centos.ustc.edu.cn/centos/5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
[root@rh5 yum.repos.d]#
3.下载以下文件并安装
yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
yum-3.2.22-20.el5.centos.noarch.rpm
yum-updatesd-0.9-2.el5.noarch.rpm
或者找个FTP站点用wget下载:
#wgetftp://ftp.pdc.kth.se/pub/bambi/centos/5.4/os/x86_64/CentOS/yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
#wget ftp://ftp.pdc.kth.se/pub/bambi/centos/5.4/os/x86_64/CentOS/yum-3.2.22-20.el5.centos.noarch.rpm
#wgetftp://ftp.pdc.kth.se/pub/bambi/centos/5.4/os/x86_64/CentOS/yum-updatesd-0.9-2.el5.noarch.rpm
[root@rh5 yumbao]# ll
total 1048
-rw-r--r-- 1 root root 1021425 Jun 29 16:38yum-3.2.22-20.el5.centos.noarch.rpm
-rw-r--r-- 1 root root 18886 Jun 29 16:36yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
-rw-r--r-- 1 root root 22666 Jun 29 16:38yum-updatesd-0.9-2.el5.noarch.rpm
[root@rh5 yumbao]# rpm -ivh yum*
4.导入KEY文件,注意大小写
[root@rh5 yumbao]# rpm --importhttp://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
[root@rh5 yumbao]# yum list