一、安装包下载
1.下载所需要的rpm安装包(可能有些包之间的小版本号不一样,可以直接去阿里云上下载)
https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-50.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
二、更换yum
1.查询yum的rpm包
rpm -qa | grep yum
rpm -qa | grep python-urlgrabber
2.删除当前yum的rpm包
rpm -qa | grep yum | xargs rpm -e --nodeps
rpm -qa | grep yum
rpm -qa | grep python-urlgrabber | xargs rpm -e --nodeps
rpm -qa | grep python-urlgrabber
3.安装新rpm包
rpm -ivh python-urlgrabber-3.10-9.el7.noarch.rpm
rpm -ivh yum-* --force --nodeps
三、更换repo源
1.删除原/etc/yum.repos.d/目录下的所有文件
rm -rf /etc/yum.repos.d/*
2.下载阿里源到/etc/yum.repos.d/目录下
wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base.repo
3.修改刚下载好的repo文件,将里面所有$releasever替换为7
vim CentOS-Base.repo
:%s/$releasever/7/g #--/g 表示一行当中如果出现了多次,每一次都替换
4.测试网络连通性
ping www.baidu.com
5.执行以下的命令
yum clean all
yum makecache
yum update