Leif160519的blog Leif160519的blog

——————

目录
RHEL7.x更换阿里云yum源
/        

RHEL7.x更换阿里云yum源

本文摘自:RHEL7.x更换阿里云yum源

环境准备

RHEL7.X,已联网

一、查询已安装的yum

rpm -qa | grep yum

二、使用root权限卸载已安装的yum源

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

三、下载并安装阿里的yum源rpm包

# 创建安放rpm包的文件夹
cd /etc/yum.repos.d/
mkdir yum-rpm && cd yum-rpm

# 下载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-3.4.3-167.el7.centos.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-53.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-53.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm

以上命令,最好一条条复制下载,如无法下载安装,根据rpm包主要关键字到阿里云CentOS-yum源库地址库中搜索,获取最新rpm包的地址后,使用wget进行下载安装即可。

四、安装rpm包

cd /etc/yum.repos.d/yum-rpm
rpm -ivh *.rpm  --force --nodeps

加上--force参数强制安装,解决安装过程中的的依赖问题。

五、下载阿里镜像到/etc/yum.repos.d/目录下

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

六、修改Centos-7.repo文件将所有$releasever替换为7

vim /etc/yum.repos.d/CentOS-Base.repo 

:%s/$releasever/7/g

七、运行以下命令

yum clean all 
yum makecache
yum update

“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill

标  题RHEL7.x更换阿里云yum源
作  者Leif160519
出  处https://github.icu/articles/2020/07/27/1595810786636.html
关于博主:坐标南京,运维工程师,如有问题探讨可以直接下方留言。
声援博主:如果您觉得文章对您有帮助,可以评论、订阅、收藏。您的鼓励是博主的最大动力!