更换redhat默认源centos7

卸载原始yum

rpm -qa|grep yum|xargs rpm -e –nodeps

需要强制卸载

下载所需文件

https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/下都可以找到可能版本会更新点

python-urlgrabber-3.10-8.el7.noarch.rpm
yum-3.4.3-154.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
yum-utils-1.1.31-42.el7.noarch.rpm

安装

[root@test01 ~]# rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm

warning: python-urlgrabber-3.10-8.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
        package python-urlgrabber-3.10-8.el7.noarch is already installed
        file /usr/lib/python2.7/site-packages/urlgrabber/grabber.pyc from install of python-urlgrabber-3.10-8.el7.noarch conflicts with file from package python-urlgrabber-3.10-8.el7.noarch
        file /usr/lib/python2.7/site-packages/urlgrabber/grabber.pyo from install of python-urlgrabber-3.10-8.el7.noarch conflicts with file from package python-urlgrabber-3.10-8.el7.noarch

[root@test01 ~]# rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-utils-1.1.31-42.el7.noarch.rpm yum-3.4.3-154.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm

warning: yum-metadata-parser-1.1.4-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 25%]
   2:yum-plugin-fastestmirror-1.1.31-4################################# [ 50%]
   3:yum-3.4.3-154.el7.centos         ################################# [ 75%]
   4:yum-utils-1.1.31-42.el7          ################################# [100%]

配置源

在/etc/yum.repos.d/下

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

替换所有的$releasever为7

:%s#$releasever#7#g

解决YUM下Loaded plugins: fastestmirror Determining fastest mirrors 的问题

修改fastestmirror.conf

vi /etc/yum/pluginconf.d/fastestmirror.conf

[main]   
enabled=0  //把1改为0  
verbose=0  
socket_timeout=3  

然后就可以正常使用了