1,查看当前版本
[root@yl yum.repos.d]# rpm -q yum
2,卸载当前yum
[root@yl yum.repos.d]# rpm -aq|grep yum|xargs rpm -e --nodeps
3,下载yum,根据自己的系统是32位或64位来决定安装什么版本
[root@yl yum.repos.d]
[root@yl yum.repos.d]
[root@yl yum.repos.d]
[root@yl yum.repos.d]
(1)进入yum配置文件目录:cd /etc/yum.repos.d/
(2)备份配置文件:mv CentOS-Base.repo CentOS-Base.repo.bak
(3)下载网易的配置:wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
下载下来的文件名为 CentOS6-Base-163.repo
(4)重命名:mv CentOS6-Base-163.repo CentOS-Base.repo
我的配置
[base]
name=CentOS-6 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/x86_64/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
[updates]
name=CentOS-6 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/x86_64/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
[extras]
name=CentOS-6 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/x86_64/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
[centosplus]
name=CentOS-6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/x86_64/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
[contrib]
name=CentOS-6 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/x86_64/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
网上有的配置里会出现$releasever和$basearch这两个变量,一定要先确认这两个环境变量是否存在,(echo一下)
如果不存在,就老老实实的用数字6和i386配,否则会出现
http://mirror.centos.org/centos/%24releasever/os/i386/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404"
这种错误(%24就是$符号嘛,)
如果你原来的就是用环境变量配的,很简单,vim下
:%s/$releasever/6/g
:%s/$basearch/i386/g
就都替换掉了(根据自己的RHEL配,我用的发行版是RHEL 6.4)
6,最后一步
[root@yl yum.repos.d]# yum clean all
[root@yl yum.repos.d]# yum makecache