最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
LinuxCentOS8中配置阿里云的yum源全过程
时间:2026-07-20 17:22:56 编辑:袖梨 来源:一聚教程网
一、检查yum安装
如果连 yum 都没有安装那就继续不下去了,得先百度下看怎么安装。

#查看安装的yumrpm -qa | grep yum
运行结果:
yum-4.4.2-11.el8.noarch
二、备份yum配置文件
yum 配置文件的目录是:/etc/yum.repos.d/
#ll /etc/yum.repos.d/
运行结果:
-rw-r--r-- 1 root root 728 2月 16 22:16 CentOS-Linux-AppStream.repo-rw-r--r-- 1 root root 713 2月 16 22:16 CentOS-Linux-BaseOS.repo-rw-r--r-- 1 root root 1139 2月 16 22:16 CentOS-Linux-ContinuousRelease.repo-rw-r--r-- 1 root root 318 2月 16 22:16 CentOS-Linux-Debuginfo.repo-rw-r--r-- 1 root root 741 2月 16 22:16 CentOS-Linux-Devel.repo-rw-r--r-- 1 root root 226 2月 16 22:16 CentOS-Linux-epel.repo-rw-r--r-- 1 root root 713 2月 16 22:16 CentOS-Linux-Extras.repo-rw-r--r-- 1 root root 728 2月 16 22:16 CentOS-Linux-FastTrack.repo-rw-r--r-- 1 root root 749 2月 16 22:16 CentOS-Linux-HighAvailability.repo-rw-r--r-- 1 root root 693 2月 16 22:16 CentOS-Linux-Media.repo-rw-r--r-- 1 root root 715 2月 16 22:16 CentOS-Linux-Plus.repo-rw-r--r-- 1 root root 733 2月 16 22:16 CentOS-Linux-PowerTools.repo-rw-r--r-- 1 root root 898 2月 16 22:16 CentOS-Linux-Sources.repo
可能不同的系统配置文件的个数都不一样,你反正先都备份就是了,我这个是阿里云的服务器自带的。
接下里我们新建一个备份的文件夹 backup
#创建一个备份目录mkdir /etc/yum.repos.d/backup#把所有的repo文件都移动到backup目录mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup
三、下载yum源配置文件
通过以下命令下载阿里云的yum源配置文件到/etc/yum.repos.d/CentOS-Base.repo,如果没有wget也可以去安装或者使用其他的方式。
#下载阿里云的yum源配置文件到/etc/yum.repos.d/CentOS-Base.repowget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
运行结果:
--2022-02-17 09:11:03-- http://mirrors.aliyun.com/repo/Centos-8.repo正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 106.15.218.232, 106.15.218.236, 106.15.218.234, ...正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|106.15.218.232|:80... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:2600 (2.5K) [application/octet-stream]正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”/etc/yum.repos.d/CentOS-Base.repo 100%[====================>] 2.54K --.-KB/s 用时 0s 2022-02-17 09:11:03 (289 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2600/2600])
这个时候我们的目录下就有一个新的文件/etc/yum.repos.d/CentOS-Base.repo
四、修改yum源配置文件
#查询目录结构vim /etc/yum.repos.d/CentOS-Base.repo
在命令模式下执行(按Esc键后,再按冒号键进入命令模式):
%s/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g
替换完后,再次进入命令模式执行:
%s/$releasever/$releasever-stream/g
最后保存修改后的内容(按Esc键后,再按冒号键,输入 wq ,按回车键即可。)
五、更新yum源配置文件
执行以下两个命令即可:
#清理一下yum clean all#生成缓存yum makecache
运行结果
CentOS-8-stream - Base - mirrors.aliyun.com 3.5 MB/s | 19 MB 00:05CentOS-8-stream - Extras - mirrors.aliyun.com 61 kB/s | 18 kB 00:00CentOS-8-stream - AppStream - mirrors.aliyun.com 2.5 MB/s | 20 MB 00:07元数据缓存已建立。
总结
至此,yum源就配置好了,需要注意的是,一个是把所有的源都备份,避免冲突,第二个是替换对应阿里云的地址,这样你生成缓存才不会报错。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持本站。
您可能感兴趣的文章:- centos8中使用yum安装nginx的详细过程
- 详解CentOS8更换yum源后出现同步仓库缓存失败的问题
- CentOS8 配置本地yum源的详细教程
- centos8 使用yum 安装 rabbitmq的教程
- CentOS8 yum/dnf 配置国内源的方法
- centos8 使用yum 安装 mongodb 4.2的方法
相关文章
- PicACG漫画网页入口_哔咔漫画官网-二次元漫画在线阅读 07-21
- 《风启之旅》最小化尸体跑动机制介绍 07-21
- 抖币充值入口-抖币充值入口地址全览 07-21
- 华为nova10和荣耀70哪个好 07-21
- zxzin/codex-academic-delivery-skills 本地安装使用教程(新手) 07-21
- DeepSeek网页版入口-无需登录 07-21