环境
系统 | centos7 |
---|
步骤
如果只是需要更换镜像文件,可直接跳转第4步。
- 使用rpm删除yum文件
rpm -qa | grep yum | xargs rpm -e --nodeps
- 下载如下安装包
如果有wget工具,则直接运行如下命令,如果下载失败,请自行去https://mirrors.aliyun.com/centos/7/os/x86_64/Packages查找新版本的rpm包,并更改版本号下载。
如果没有wget工具,只能自己去上面那个网页下载包啦。
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
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-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
- 安装
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-3.4.3-168.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm yum-utils-1.1.31-54.el7_8.noarch.rpm python-urlgrabber-3.10-10.el7.noarch.rpm --force --nodeps
- 下载阿里云镜像并替换原配置文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
- 修改下载的文件,替换$releaserver为7
:%s/$releasever/7/g
- 运行如下命令完成安装
yum clean all
yum makecache