如何将CentOS8更换国内源

59e2e73770ddb56af93ec6959b79108c.png

CentOS 8操作系统版本在2021年12月31日结束了生命周期(EOL),Linux社区已不再维护该操作系统版本。因此,CentOS 8的源地址http://mirror.centos.org/centos/8/的内容已被移除。

在这种情况下,如果业务在过渡期仍需使用CentOS 8,那么就需要更新备用源。而由于官方的源已经去掉,第三方也就无法再同步,所以第三方的源也就不复存在了。但是大部分第三方都把最后的源做了备份并弄了个新的地址,方便过渡期使用。阿里云的源镜像服务器在国内,使用yum安装服务时下载速度会更快些。

12a2a11e0d3f610a85d5378a5bd02db1.png

更换源

cd /etc/yum.repos.d

建议先进行备份:

mv CentOS-Base.repo CentOS-Base.repo.bak

更换 CentOS-Base.repo 为 阿里云的 CentOS-Base.repo

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

更新yum缓存

yum clean all
yum makecache

若 yum makecache 出现以下错误,则需更换 epel.repo

- Status code: 404 for http://archives.fedoraproject.org/pub/archive/epel/8/Everything/x86_64/repodata/repomd.xml (IP: 38.145.60.23)
Error: Failed to download metadata for repo 'epel': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

更换 epel.repo 为 阿里云的 epel.repo

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

注:更新源/镜像后,记得更新yum缓存~

若 yum makecache 再次出现以下错误,则需更换 epel-modular.repo

Errors during downloading metadata for repository 'epel-modular':
  - Status code: 404 for https://mirrors.fedoraproject.org/metalink?repo=epel-modular-3&arch=x86_64&infra=$infra&content=$contentdir (IP: 38.145.60.20)
Error: Failed to download metadata for repo 'epel-modular': Cannot prepare internal mirrorlist: Interrupted by signal

更换 epel-modular.repo 为 阿里云的 epel-modular.repo

由于笔者在https://mirrors.aliyun.com/repo上未找到epel-modular.repo,因此手动将epel-modular.repo中的baseurl替换为aliyun(与epel.repo的相同)。如下:注释的 baseurl 是旧的 url,当前 epel-modular.repo 使用的 baseurl 同 epel.repo 中的 baseurl 。

[epel-modular]
name=Extra Packages for Enterprise Linux Modular $releasever - $basearch
# It is much more secure to use the #metalink, but if you wish to use a local mirror
# place it's address here.
baseurl=http://mirrors.aliyun.com/epel/7/$basearch
#baseurl=http://archives.fedoraproject.org/pub/archive/epel/$releasever/Modular/$basearch
#metalink=https://mirrors.fedoraproject.org/#metalink?repo=epel-modular-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=1
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
[epel-modular-debuginfo]
name=Extra Packages for Enterprise Linux Modular $releasever - $basearch - Debug
# It is much more secure to use the #metalink, but if you wish to use a local mirror
# place it's address here.
baseurl=http://mirrors.aliyun.com/epel/7/$basearch/debug
#baseurl=http://archives.fedoraproject.org/pub/archive/epel/$releasever/Modular/$basearch/debug
#metalink=https://mirrors.fedoraproject.org/#metalink?repo=epel-modular-debug-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1
[epel-modular-source]
name=Extra Packages for Enterprise Linux Modular $releasever - $basearch - Source
# It is much more secure to use the #metalink, but if you wish to use a local mirror
# place it's address here.
baseurl=http://mirrors.aliyun.com/epel/7/SRPMS
#baseurl=http://archives.fedoraproject.org/pub/archive/epel/$releasever/Modular/SRPMS
#metalink=https://mirrors.fedoraproject.org/#metalink?repo=epel-modular-source-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值