CentOS8国内源

11 篇文章 0 订阅

CentOS8中引入了智能镜像加速,但是实际使用还是有点不太行,所以有时候还是需要指定一个国内的源站进行加速才行,下面就列出国内常用的一些加速站吧

1、模板(阿里云)

1.1、写入配置文件

这是一条命令

echo '
[base]
name=CentOS-$releasever - Base
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
[PowerTools]
name=CentOS-$releasever - PowerTools
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official


[AppStream]
name=CentOS-$releasever - AppStream
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official' > /etc/yum.repos.d/CentOS-Base.repo

执行结果

[root@localhost yum.repos.d]# echo '
> [base]
> name=CentOS-$releasever - Base
> failovermethod=priority
> baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
> gpgcheck=1
> gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
>  
> #additional packages that may be useful
> [extras]
> name=CentOS-$releasever - Extras
> failovermethod=priority
> baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
> gpgcheck=1
> gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
>  
> #additional packages that extend functionality of existing packages
> [centosplus]
> name=CentOS-$releasever - Plus
> failovermethod=priority
> baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/
> gpgcheck=1
> enabled=0
> gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
>  
> [PowerTools]
> name=CentOS-$releasever - PowerTools
> failovermethod=priority
> baseurl=https://mirrors.aliyun.com/centos/$releasever/PowerTools/$basearch/os/
> gpgcheck=1
> enabled=0
> gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
> 
> 
> [AppStream]
> name=CentOS-$releasever - AppStream
> failovermethod=priority
> baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
> gpgcheck=1
> gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official' > /etc/yum.repos.d/CentOS-Base.repo

1.2、验证

执行下面的命令验证是否成功配置

yum clean all
yum makecache 

在这里插入图片描述

2、常用站点

2.1、前提条件

  • 需要执行第一步的命令生成一个模板,然后接下来的命令才能生效
  • 每次执行替换必须保持第一步的模板

2.2、腾讯云

sed -i 's#https://mirrors.aliyun.com/#https://mirrors.cloud.tencent.com/#g' /etc/yum.repos.d/CentOS-Base.repo

2.3、网易云

sed -i 's#https://mirrors.aliyun.com/#http://tel.mirrors.163.com/#g' /etc/yum.repos.d/CentOS-Base.repo

2.4、中国科学技术大学

sed -i 's#https://mirrors.aliyun.com/#https://mirrors.ustc.edu.cn/#g' /etc/yum.repos.d/CentOS-Base.repo

2.5、清华大学

sed -i 's#https://mirrors.aliyun.com/#https://mirrors.tuna.tsinghua.edu.cn/#g' /etc/yum.repos.d/CentOS-Base.repo

2.6、华为镜像站

sed -i 's#https://mirrors.aliyun.com/#https://mirrors.huaweicloud.com/#g' /etc/yum.repos.d/CentOS-Base.repo

3、替换演示

[root@localhost yum.repos.d]# echo '
> [base]
> name=CentOS-$releasever - Base
> failovermethod=priority
> baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
> gpgcheck=1
> gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
>  
> #additional packages that may be useful
> [extras]
> name=CentOS-$releasever - Extras
> failovermethod=priority
> baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
> gpgcheck=1
> gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
>  
> #additional packages that extend functionality of existing packages
> [centosplus]
> name=CentOS-$releasever - Plus
> failovermethod=priority
> baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/
> gpgcheck=1
> enabled=0
> gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
>  
> [PowerTools]
> name=CentOS-$releasever - PowerTools
> failovermethod=priority
> baseurl=https://mirrors.aliyun.com/centos/$releasever/PowerTools/$basearch/os/
> gpgcheck=1
> enabled=0
> gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
> 
> 
> [AppStream]
> name=CentOS-$releasever - AppStream
> failovermethod=priority
> baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
> gpgcheck=1
> gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official' > /etc/yum.repos.d/CentOS-Base.repo
[root@localhost yum.repos.d]# sed -i 's#https://mirrors.aliyun.com/#https://mirrors.huaweicloud.com/#g' /etc/yum.repos.d/CentOS-Base.repo
[root@localhost yum.repos.d]# yum clean all 
27 文件已删除
[root@localhost yum.repos.d]# yum makecache 
CentOS-8 - Base                                                                                                                                                                                                   2.9 MB/s | 2.2 MB     00:00    
CentOS-8 - Extras                                                                                                                                                                                                  21 kB/s | 8.6 kB     00:00    
CentOS-8 - AppStream                                                                                                                                                                                              3.7 MB/s | 5.8 MB     00:01    
Zabbix Official Repository - x86_64                                                                                                                                                                               404 kB/s | 248 kB     00:00    
Zabbix Official Repository non-supported - x86_64                                                                                                                                                                 7.0 kB/s | 2.3 kB     00:00    
元数据缓存已建立。
[root@localhost yum.repos.d]# cat CentOS-Base.repo | grep htt
baseurl=https://mirrors.huaweicloud.com/centos/$releasever/BaseOS/$basearch/os/
gpgkey=https://mirrors.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-Official
baseurl=https://mirrors.huaweicloud.com/centos/$releasever/extras/$basearch/os/
gpgkey=https://mirrors.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-Official
baseurl=https://mirrors.huaweicloud.com/centos/$releasever/centosplus/$basearch/os/
gpgkey=https://mirrors.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-Official
baseurl=https://mirrors.huaweicloud.com/centos/$releasever/PowerTools/$basearch/os/
gpgkey=https://mirrors.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-Official
baseurl=https://mirrors.huaweicloud.com/centos/$releasever/AppStream/$basearch/os/
gpgkey=https://mirrors.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-Official
[root@localhost yum.repos.d]# 
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

坐公交也用券

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值