1.检查是否安装yum软件包.
[root@localhost ~]# rpm -qa |grep yum
yum-utils-1.1.31-24.el7.noarch
yum-langpacks-0.4.2-3.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-rhn-plugin-2.0.1-4.el7.noarch
PackageKit-yum-0.8.9-11.el7.x86_64
yum-3.4.3-118.el7.noarch
2.删除RedHat自带yum软件包.
[root@localhost ~]# rpm -qa | grep yum | xargs rpm -e --nodeps
[root@localhost ~]# rpm -qa | grep yum
3.下载yum软件包,使用CentOS 7的yum软件包.
使用阿里云地址下载
[root@localhost ~]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metada ta-parser-1.1.4-10.el7.x86_64.rpm
[root@localhost ~]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3- 150.el7.centos.noarch.rpm
[root@localhost ~]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin -fastestmirror-1.1.31-40.el7.noarch.rpm
[root@localhost ~]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils- 1.1.31-40.el7.noarch.rpm
[root@localhost ~]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-url grabber-3.10-8.el7.noarch.rpm
(rpm -qa|grep python-urlgrabber|xargs rpm -e --nodeps )
或使用163地址下载
[root@localhost ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
[root@localhost ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-125.el7.centos.noarch.rpm
[root@localhost ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
[root@localhost ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-29.el7.noarch.rpm
4.安装Yum软件包.
注意:单独安装包可能会产生依赖包(如yum和yum-fastestmirror会相互依赖)
[root@localhost ~]# rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm
[root@localhost ~]# rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-3.4.3-150.el7 .centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm
5.更换Yum源,使用阿里云或163的Yum源.
5.1 备份原镜像文件
5.2 下载CentOS7-Base.repo到/etc/yum.repos.d/
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS7-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.re po
5.3 修改CentOS-Base.repo文件中的$releasever全部替换为版本号7. 或下载下面文件上传至/etc/yum.repos.d 目录.
5.4 运行 yum makecache 生成缓存.
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
[root@localhost ~]# yum update
[root@localhost ~]# yum repolist
原文地址:http://whoami2.blog.51cto.com/6430243/1943991