CentOS镜像源配置

CentOS镜像源配置

1. 基础镜像源配置

1.1 简介

CentOS,是基于Red Hat Linux提供的可自由使用源代码的企业级Linux发行版本;是一个稳定,可预测,可管理和可复制的免费企业级计算平台。

下载地址: https://mirrors.aliyun.com/centos/

1.2 相关仓库

  • CentOS 过期源(centos-vault):https://developer.aliyun.com/mirror/centos-vault
  • CentOS arm源(centos-altarch):https://developer.aliyun.com/mirror/centos-altarch/
  • CentOS Stream源(centos-stream):https://developer.aliyun.com/mirror/centos-stream
  • CentOS debuginfo源(centos-debuginfo):https://developer.aliyun.com/mirror/centos-debuginfo/

1.3 配置方法

通知:CentOS 8操作系统版本结束了生命周期(EOL),Linux社区已不再维护该操作系统版本。建议您切换到Anolis或Alinux。如果您的业务过渡期仍需要使用CentOS 8系统中的一些安装包,请根据下文切换CentOS 8的源。

以CentOS配置阿里云镜像源为例,操作如下:

  1. 备份原始文件

    sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    
  2. 下载阿里云镜像源配置文件

    # Centos8下载,centos8官方源已下线,建议切换centos-vault源
    sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
    # 或者
    sudo wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
    
    # Centos7下载
    sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
    # 或者
    sudo wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
    
    # Centos6下载,centos6官方源已下线,建议切换centos-vault源
    sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
    # 或者
    sudo wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
    
  3. 清理缓存并生成新缓存

    sudo yum clean all
    sudo yum makecache
    
  4. 其他

非阿里云ECS用户会出现 Couldn’t resolve host ‘mirrors.cloud.aliyuncs.com’ 信息,不影响使用。用户也可自行修改相关配置:

# 删除配置文件中如下两行
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

1.4 相关链接

  • 官方主页: http://www.centos.org/
  • 邮件列表: https://wiki.centos.org/GettingHelp/ListInfo
  • 论坛: https://forums.centos.org/
  • 文档: http://www.centos.org/docs/
  • Wiki: http://wiki.centos.org/

2. epel源配置

2.1 简介

EPEL(Extra Packages for Enterprise Linux), 是由Fedora Special Interest Group维护的Enterprise Linux(RHEL、CentOS)中经常用到的包。

下载地址:https://mirrors.aliyun.com/epel/

2.2 相关仓库

  • epel过期源(epel-archive):https://developer.aliyun.com/mirror/epel-archive

2.3 配置方法

  1. 备份(如有配置其他epel源)
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
  1. 下载新repo 到/etc/yum.repos.d/

epel(RHEL 8/CentOS8)
1)安装 epel 配置包

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

2)将 repo 配置中的地址替换为阿里云镜像站地址

sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*

epel(RHEL 8/CentOS8)

wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

epel(RHEL 8/CentOS8) (epel6官方源已下线,建议切换epel-archive源)

wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-archive-6.repo

2.4 相关链接

  • 官方主页:https://fedoraproject.org/wiki/EPEL

3. 其他可用镜像源

  1. centos | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
  2. CentOS - USTC Mirror Help
  3. CentOS (tencent.com)
  • 8
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
CentOS 7.9 中重新配置镜像源,你可以按照以下步骤进行: 1.备份原有的镜像源配置文件 在开始更改镜像源之前,最好先备份一下原有的镜像源配置文件,以防在更改后出现问题。你可以使用以下命令备份 CentOS 官方的镜像源配置文件: ``` sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak ``` 2.选择一个适合你的镜像源 在开始更改镜像源之前,你需要选择一个适合你的镜像源。你可以选择 CentOS 官方的镜像源,也可以选择其他第三方镜像源。在选择镜像源时,你需要考虑镜像源的稳定性、速度和可靠性等因素。 3.编辑镜像源配置文件 编辑镜像源配置文件,将原有的镜像源地址替换为你选择的新镜像源地址。你可以使用以下命令编辑 CentOS 官方的镜像源配置文件: ``` sudo vi /etc/yum.repos.d/CentOS-Base.repo ``` 在编辑器中,找到以 [base] 开头的节,将其中的 baseurl 地址替换为你选择的镜像源地址。例如,如果你选择了清华大学的镜像源,可以将 baseurl 替换为: ``` baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/ ``` 注意:如果你使用的是其他版本的 CentOS,$releasever 可能需要替换为相应版本号。 4.清除缓存并测试新镜像源 在修改镜像源配置文件后,你需要清除缓存并测试新镜像源。你可以使用以下命令清除 yum 缓存并测试新镜像源: ``` sudo yum clean all sudo yum makecache sudo yum update ``` 这些命令将清除 yum 的缓存并使用新的镜像源更新系统软件包。如果一切正常,你应该能够顺利地更新系统软件包。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

lldhsds

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

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

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

打赏作者

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

抵扣说明:

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

余额充值