CentOS7配置国内yum源与epel源

本文介绍了如何在CentOS7系统中配置国内的YUM源,包括备份原有repo文件,从网易和阿里开源镜像站下载对应版本的repo文件,并详细说明了安装EPEL源的过程,利用阿里开源镜像提供EPEL源,以提升软件更新速度。
摘要由CSDN通过智能技术生成

国内yum源

1.首先进入/etc/yum.repos.d/目录下,新建一个repo_bak目录,用于保存系统中原来的repo文件

[root@localhost ~]# cd /etc/yum.repos.d/

[root@localhost yum.repos.d]# mkdir repo_bak

[root@localhost yum.repos.d]# mv *.repo repo_bak/

2.在CentOS中配置使用网易和阿里的开源镜像

到网易和阿里开源镜像站点下载系统对应版本的repo文件


[root@localhost yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo
--2020-12-29 18:54:19--  http://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 182.131.24.238, 182.131.24.242, 182.131.24.243, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|182.131.24.238|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “Centos-7.repo”

100%[=============================================>] 2,523       --.-K/s 用时 0s      

2020-12-29 18:54:19 (309 MB/s) - 已保存 “Centos-7.repo” [2523/2523])




[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
--2020-12-29 18:55:59--  http://mirrors.163.com/.help/CentOS7-Base-163.repo
正在解析主机 mirrors.163.com (mirrors.163.com)... 123.53.139.70, 123.53.139.69, 123.53.139.71
正在连接 mirrors.163.com (mirrors.163.com)|123.53.139.70|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1572 (1.5K) [application/octet-stream]
正在保存至: “CentOS7-Base-163.repo”

100%[=============================================>] 1,572       --.-K/s 用时 0.01s   

2020-12-29 18:56:01 (126 KB/s) - 已保存 “CentOS7-Base-163.repo” [1572/1572])


查看下载

[root@localhost yum.repos.d]# ls
CentOS7-Base-163.repo  Centos-7.repo  repo_bak

[root@localhost yum.repos.d]# yum clean all               # 清除系统所有的yum缓存
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
正在清理软件源: base extras updates
Cleaning up list of fastest mirrors


[root@localhost yum.repos.d]# yum makecache           # 生成yum缓存
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repos
CentOS 7 配置阿里云的 Yum EPEL (Extra Packages for Enterprise Linux) 可以帮助您获取更多的软件包,尤其是那些官方仓库未包含的扩展组件。以下是详细的步骤: **配置阿里云Yum源**: 1. **首先备份原有repo文件**: ``` sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base-backup.repo ``` 2. **添加阿里云基础镜像**: - 打开 `vim` 编辑器编辑 `/etc/yum.repos.d/CentOS-Base.repo` 或者使用文本编辑器,如 `nano`: ``` nano /etc/yum.repos.d/CentOS-Base.repo ``` 添加以下内容到文件末尾(替换 `<YOUR-ALIYUN-MIRROR>` 为实际的镜像地址): ```bash [base] name=阿里云基础镜像 baseurl=<YOUR-ALIYUN-MIRROR>centos/7/os/x86_64/ gpgcheck=0 enabled=1 ``` 3. **保存并关闭编辑器**: - 如果使用 `vi` 或 `vim`, 输入 `:wq` 然后回车。 - 如果使用 `nano`, 按 `Ctrl+X`, 然后 `Y` 确认保存,最后 `Enter`。 4. **刷新缓存并安装新的yum源**: ``` sudo yum clean all sudo yum makecache fast ``` **配置EPEL**: 1. **下载并安装 epel-release 包**: ``` wget https://mirrors.aliyun.com/epel/7/x86_64/epel-release-7-15.noarch.rpm sudo rpm -Uvh epel-release-7-15.noarch.rpm ``` 2. **检查是否安装成功**: ``` rpm -qa | grep epel-release ``` 3. **将EPEL添加到yum配置文件**: 同样打开或编辑 `/etc/yum.repos.d/epel.repo` 文件,然后添加以下行: ``` [epel] name=Extra Packages for Enterprise Linux 7 - $basearch mirrorlist=https://mirrors.aliyun.com/epel/7/$basearch/$basearch-repo-list.txt gpgcheck=1 gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7 enabled=1 ``` 4. **更新EPEL缓存和安装新包**: ``` sudo yum update ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值
>