centos 更新国内yum源

centos 7

1, 备份原有repo文件

2,使用阿里yum源

wget -O /etc/yum.repos.d/CentOS7-Aliyun.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel-7-Aliyun.repo http://mirrors.aliyun.com/repo/epel-7.repo

3,centos7 更新epel源

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
4, 更新缓存

yum clean all

yum makecache

#查看源列表

yum repolist all

centos 8

1,备份原有repo文件

cd /etc/yum.repos.d/ && mkdir backup && mv *repo backup/

2,下载阿里源文件

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

3,更新源文件的地址

sed -i -e "s|mirrors.cloud.aliyuncs.com|mirrors.aliyun.com|g " /etc/yum.repos.d/CentOS-*

sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-*

4,安装epel源,centos8 和centos7 完全不同

yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm

安装后,在/etc/yum.repos.d目录下会多出下面的文件

5, 将将 repo 配置中的地址替换为阿里云镜像站地址
sed -i 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*

6,生成缓存

yum clean all && yum makecache

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CentOS 7是一款流行的Linux操作系统,它可以使用yum(Yellowdog Updater, Modified)进行软件包管理。然而,由于某些原因,CentOS官方yum源速度较慢,对于国内用户来说,使用国内yum源更为稳定和方便。 国内yum源有很多,比如阿里云、网易、豆瓣等。这些源提供了丰富的软件包资源,用户可以根据自己的需要选择相应的源进行配置。以下是配置CentOS 7国内yum源的步骤: 首先,备份CentOS官方yum源配置文件: cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 然后,使用vi编辑器打开CentOS-Base.repo文件: vi /etc/yum.repos.d/CentOS-Base.repo 将[base]、[updates]、[extra]和[centosplus]等节的baseurl一行注释掉,添加如下内容: [base] name=CentOS-$releasever - Base - Aliyun baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ gpgcheck=0 enabled=1 [updates] name=CentOS-$releasever - Updates - Aliyun baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ gpgcheck=0 enabled=1 [extras] name=CentOS-$releasever - Extras - Aliyun baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ gpgcheck=0 enabled=1 [centosplus] name=CentOS-$releasever - Plus - Aliyun baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ gpgcheck=0 enabled=1 保存修改并退出vi编辑器。 最后,运行yum makecache命令,更新yum缓存: yum makecache 至此,配置CentOS 7国内yum源完成。用户可以运行yum命令安装所需的软件包。需要注意的是,在使用国内yum源时,可能会存在软件包不完整或者与官方源不一致的情况,用户需要谨慎选择源并在下载软件包时进行验证。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值