开发环境——RHEL7更换yum源

一、删除RHN注册和订阅提示

查找subscription-manager相关组件:
rpm -qa|grep subscription-manager
删除subscription-manager相关组件:
sudo yum remove subscription-manager
查找rhn相关组件:
rpm -qa|grep rhn
删除rhn相关组件:
sudo yum remove rhn-check

二、yum安装

1、yum卸载

查询当前RHEL7.3的yum安装包:
rpm -qa |grep yum
强制删除当前yum:
sudo rpm -qa|grep yum|xargs rpm -e --nodeps
再次查询yum是否删除:
rpm -qa |grep yum

2、更新rpm

由于最新的yum安装包依赖rpm-4.11.3-32.el7.x86_64.rpm,所以必须升级rpm到rpm-4.11.3-32.el7.x86_64.rpm
在http://mirrors.163.com/centos/7/os/x86_64/Packages/ 下载如下rpm安装包:

rpm-4.11.3-32.el7.x86_64.rpm
rpm-build-4.11.3-32.el7.x86_64.rpm
rpm-build-libs-4.11.3-32.el7.x86_64.rpm
rpm-libs-4.11.3-32.el7.x86_64.rpm
rpm-devel-4.11.3-32.el7.x86_64.rpm

强制安装所有的rpm安装包:
sudo rpm -ivh rpm-* --force

3、安装yum

在http://mirrors.163.com/centos/7/os/x86_64/Packages/ 下载如下yum安装包:

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

安装:

sudo rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm 
sudo rpm -ivh yum-*

安装成功,查询yum版本
yum --version

4、更新yum源为阿里云源

下载源仓库文件:
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
将CentOS-Base.repo文件中的$releasever全部替换为版本号7
更新仓库:

yum clean all
yum makecache
sudo yum update