centos8更换国内源(阿里源)

本文详细介绍了如何将CentOS8的默认源更改为阿里源,包括备份旧配置文件,下载并替换新的CentOS-Base.repo,生成缓存,最终实现快速的软件安装。

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

1. 备份旧的配置文件

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2. 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

并替换部分字段(非阿里云机器需要做)

sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

3.生成缓存

 yum makecache

 4.配置完毕,正常安装软件(速度飞快)

[root@test ~]# yum -y install vim
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
上次元数据过期检查:0:00:15 前,执行于 2020年05月13日 星期三 03时54分59秒。
依赖关系解决。
=============================================================================================================================================================================================================================================
 软件包                                                    架构                                                版本                                                             仓库                                                    大小
=============================================================================================================================================================================================================================================
安装:
 vim-enhanced                                              x86_64                                              2:8.0.1763-13.el8                                                AppStream                                              1.4 M

事务概要
=============================================================================================================================================================================================================================================
安装  1 软件包

总计:1.4 M
安装大小:3.4 M
下载软件包:
[SKIPPED] vim-enhanced-8.0.1763-13.el8.x86_64.rpm: Already downloaded
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                                                                         136 MB/s | 1.4 MB     00:00
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                                                                                                                                              1/1
  安装    : vim-enhanced-2:8.0.1763-13.el8.x86_64                                                                                                                                                                                        1/1
  运行脚本: vim-enhanced-2:8.0.1763-13.el8.x86_64                                                                                                                                                                                        1/1
  验证    : vim-enhanced-2:8.0.1763-13.el8.x86_64                                                                                                                                                                                        1/1
Installed products updated.

已安装:
  vim-enhanced-2:8.0.1763-13.el8.x86_64

完毕!

 

 

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值