yum源更换为阿里源及制作yum本地源

本文详述如何将CentOS的yum源更换为阿里云镜像站,并指导如何制作本地yum源,包括从发行版光盘创建和自定义本地存储路径。步骤涵盖配置repo文件、创建缓存、检查可用仓库以及使用createrepo制作repodata。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一.更换yum源为阿里源

1.由于centos自带的yum源在国内使用时有时候速度会很慢,导致yum在线安装速度缓慢。这时候就需要yum源为国内的一些镜像站点。

2.首先访问阿里云镜像站点:http://mirrors.aliyun.com

3.选择对应的linux发行版(此次使用CentOS Linux release 7.4.1708进行测试)
在这里插入图片描述
4.进入7.6.1810版本,此次准备创建4个repo
1)os/:即发行版光盘上附带的所有基础rpm包
2)updates/ :所有更新的rpm包
3)extras/ :附带的一些额外包
4)centosplus/ :额外增添的一些包
在这里插入图片描述
5.找到repodata所在目录并记录其路径:
在这里插入图片描述
6.repo的配置文件在/etc/yum.repos.d/*repo,制作名称为CentOS-Base.repo;并将之前的CentOS-Base.repo更改为CentOS-Base.repo.apk
1)开始编辑CentOS-Base.repo文件

[aliyun]      仓库ID
name=this is os repo  仓库介绍
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/       repo链接,$releasever为版本号,$basearch为基础架构
enabled=1     开启仓库
gpgcheck=1    检查其rpm包的合法性及完整性
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7      秘钥地址

7.依据上面步骤添加剩余三个仓库,并且将网易镜像链接也添加进来做防范措施.。

[aliyun]
name=this is os repo
failovermethod=priority    出错防范措施,为顺序执行
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        https://mirrors.163.com/centos/$releasever/os/$basearch
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

[updates]
name=this is updates repo
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        https://mirrors.163.com/centos/$releasever/updates/$basearch
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

[centosplus]
name=this is centosplus repo
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        https://mirrors.163.com/centos/$releasever/centosplus/$basearch
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

[extras]
name=this is extras repo
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        https://mirrors.163.com/centos/$releasever/extras/$basearch
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#https://mirrors.163.com/centos/RPM-GPG-KEY
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值