跳转到内容

为CentOS Stream 9配置镜像

考虑到国际网络访问体验不佳,可以将CentOS Stream 9的安装源配置为国内镜像。建议使用清华大学的镜像站点,可以在这里找到其中关于CentOS Stream 9的镜像配置说明。

配置步骤

可遵照以下步骤进行配置:

  1. 备份现有的安装源配置文件:
    Terminal window
    sudo cp /etc/yum.repos.d/centos.repo /etc/yum.repos.d/centos.repo.backup
    sudo cp /etc/yum.repos.d/centos-addons.repo /etc/yum.repos.d/centos-addons.repo.backup
  2. 使用下面的内容来替换掉centos.repo文件中的所有内容(这些内容可以在上述说明页面中找到):
    centos.repo
    [baseos]
    name=CentOS Stream $releasever - BaseOS
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/BaseOS/$basearch/os
    # metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    countme=1
    enabled=1
    [baseos-debuginfo]
    name=CentOS Stream $releasever - BaseOS - Debug
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/BaseOS/$basearch/debug/tree/
    # metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-debug-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0
    [baseos-source]
    name=CentOS Stream $releasever - BaseOS - Source
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/BaseOS/source/tree/
    # metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-source-$stream&arch=source&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0
    [appstream]
    name=CentOS Stream $releasever - AppStream
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/AppStream/$basearch/os
    # metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    countme=1
    enabled=1
    [appstream-debuginfo]
    name=CentOS Stream $releasever - AppStream - Debug
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/AppStream/$basearch/debug/tree/
    # metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-debug-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0
    [appstream-source]
    name=CentOS Stream $releasever - AppStream - Source
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/AppStream/source/tree/
    # metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-source-$stream&arch=source&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0
    [crb]
    name=CentOS Stream $releasever - CRB
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/CRB/$basearch/os
    # metalink=https://mirrors.centos.org/metalink?repo=centos-crb-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    countme=1
    enabled=1
    [crb-debuginfo]
    name=CentOS Stream $releasever - CRB - Debug
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/CRB/$basearch/debug/tree/
    # metalink=https://mirrors.centos.org/metalink?repo=centos-crb-debug-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0
    [crb-source]
    name=CentOS Stream $releasever - CRB - Source
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/CRB/source/tree/
    # metalink=https://mirrors.centos.org/metalink?repo=centos-crb-source-$stream&arch=source&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0
  3. 使用下面的内容来替换掉centos-addons.repo文件中的所有内容:
    centos-addons.repo
    [highavailability]
    name=CentOS Stream $releasever - HighAvailability
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/HighAvailability/$basearch/os
    # metalink=https://mirrors.centos.org/metalink?repo=centos-highavailability-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    countme=1
    enabled=0
    [highavailability-debuginfo]
    name=CentOS Stream $releasever - HighAvailability - Debug
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/HighAvailability/$basearch/debug/tree/
    # metalink=https://mirrors.centos.org/metalink?repo=centos-highavailability-debug-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0
    [highavailability-source]
    name=CentOS Stream $releasever - HighAvailability - Source
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/HighAvailability/source/tree/
    # metalink=https://mirrors.centos.org/metalink?repo=centos-highavailability-source-$stream&arch=source&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0
    [nfv]
    name=CentOS Stream $releasever - NFV
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/NFV/$basearch/os
    # metalink=https://mirrors.centos.org/metalink?repo=centos-nfv-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    countme=1
    enabled=0
    [nfv-debuginfo]
    name=CentOS Stream $releasever - NFV - Debug
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/NFV/$basearch/debug/tree/
    # metalink=https://mirrors.centos.org/metalink?repo=centos-nfv-debug-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0
    [nfv-source]
    name=CentOS Stream $releasever - NFV - Source
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/NFV/source/tree/
    # metalink=https://mirrors.centos.org/metalink?repo=centos-nfv-source-$stream&arch=source&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0
    [rt]
    name=CentOS Stream $releasever - RT
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/RT/$basearch/os
    # metalink=https://mirrors.centos.org/metalink?repo=centos-rt-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    countme=1
    enabled=0
    [rt-debuginfo]
    name=CentOS Stream $releasever - RT - Debug
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/RT/$basearch/debug/tree/
    # metalink=https://mirrors.centos.org/metalink?repo=centos-rt-debug-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0
    [rt-source]
    name=CentOS Stream $releasever - RT - Source
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/RT/source/tree/
    # metalink=https://mirrors.centos.org/metalink?repo=centos-rt-source-$stream&arch=source&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0
    [resilientstorage]
    name=CentOS Stream $releasever - ResilientStorage
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/ResilientStorage/$basearch/os
    # metalink=https://mirrors.centos.org/metalink?repo=centos-resilientstorage-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    countme=1
    enabled=0
    [resilientstorage-debuginfo]
    name=CentOS Stream $releasever - ResilientStorage - Debug
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/ResilientStorage/$basearch/debug/tree/
    # metalink=https://mirrors.centos.org/metalink?repo=centos-resilientstorage-debug-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0
    [resilientstorage-source]
    name=CentOS Stream $releasever - ResilientStorage - Source
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/ResilientStorage/source/tree/
    # metalink=https://mirrors.centos.org/metalink?repo=centos-resilientstorage-source-$stream&arch=source&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0
    [extras-common]
    name=CentOS Stream $releasever - Extras packages
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/SIGs/$releasever-stream/extras/$basearch/extras-common
    # metalink=https://mirrors.centos.org/metalink?repo=centos-extras-sig-extras-common-$stream&arch=$basearch&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    countme=1
    enabled=1
    [extras-common-source]
    name=CentOS Stream $releasever - Extras packages - Source
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/SIGs/$releasever-stream/extras/source/extras-common
    # metalink=https://mirrors.centos.org/metalink?repo=centos-extras-sig-extras-common-source-$stream&arch=source&protocol=https,http
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512
    gpgcheck=1
    repo_gpgcheck=0
    metadata_expire=6h
    enabled=0

相关资源

可以直接下载上述2个配置好的文件,然后将它们放到/etc/yum.repos.d/路径中: