Centos7的Yum源搭建

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值