RedHat7更换Yum源

2023-12-20 16:24:11

清除旧 yum 版本

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

下载安装centos的yum文件

mkdir yum_temp && cd yum_temp

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm --no-check-certificate
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm --no-check-certificate
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm --no-check-certificate

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm  --no-check-certificate

rpm -ivh *.rpm --force --nodeps

cd .. && rm -rf yum_temp

下载替换centos源

rm -rf /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# -O指定文件
sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo

清缓存

yum clean all

yum makecache

yum list

# 更新软件包(可不操作)(不建议操作,更新后有问题还没解决)
yum update -y

文章来源:https://blog.csdn.net/m0_56181660/article/details/135080366
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。