1.备份系统自带的yum源配置文件
mkdir /root/yum_backup;
cp /etc/yum.repos.d/* /root/yum_backup/;
2.配置Yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3.清理yum缓存并生成新的缓存
yum clean all;
yum makecache;
执行【yum clean all】命令有可能报错:
This system is not registered with an entitlement server. You can use subscription-manager to register
4.解决办法:
1.首先,编辑subscription-manager.conf,把enabled值由1改为0,意为禁用 subscription-manager
vim /etc/yum/pluginconf.d/subscription-manager.conf
2.获取到一个名为CentOS-Base.repo的镜像源后,编辑所有的$releasever,替换为数字7,保存退出。
sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
3.将repo镜像文件名CentOS-Base.repo名字改为redhat.repo,配置成功
mv CentOS-Base.repo redhat.repo
4.删除无用的镜像源
sed -i '/aliyuncs/d' /etc/yum.repos.d/redhat.repo
5.重新清理构建缓存
yum clean all;
yum makecache;
6.查看yum源
yum repolist all
标签:repo,CentOS,repos,Centos7,etc,Base,yum,Yum,搭建
From: https://blog.csdn.net/m0_57592634/article/details/143741813