技术交流QQ群:①185473046   ②190706903   ③203744115   网站地图
登录

下次自动登录
现在的位置: 首页CentOS>正文
CentOS-7.x官方停止维护后yum源失效解决办法
2024年08月28日 CentOS 暂无评论 ⁄ 被围观 1,361次+

截止目前CentOS-7.x官方已经停止维护,yum命令默认已经无法使用。

CentOS官方提供了一个旧版软件存档http://vault.centos.org/,我们可以使用这个连接替换yum源

1、查询当前系统版本

cat /etc/redhat-release

当前系统版本是CentOS Linux release 7.9.2009 (Core)

yum install wget #测试安装软件,默认无法使用yum命令

2、创建yum源文件

#备份默认的源文件

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo-backup

vi /etc/yum.repos.d/CentOS-Base.repo #编辑源文件

[base]

name=CentOS-7.9.2009

enabled=1

failovermethod=priority

baseurl=https://vault.centos.org/7.9.2009/os/$basearch/

gpgcheck=1

gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-7

[updates]

name=CentOS-7.9.2009

enabled=1

failovermethod=priority

baseurl=https://vault.centos.org/7.9.2009/updates/$basearch/

gpgcheck=1

gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-7

[extras]

name=CentOS-7.9.2009

enabled=1

failovermethod=priority

baseurl=https://vault.centos.org/7.9.2009/extras/$basearch/

gpgcheck=1

gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-7

:wq! #保存退出

yum clean all

yum makecache #生成缓存

yum install wget #再次测试安装软件

成功使用yum安装了wget

3、配置其他yum源

3.1、配置阿里云的yum源

下载阿里云的 yum 源配置文件,使用 wget 命令从阿里云下载新的 yum 源配置文件。

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo-vault-backup

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

yum clean all

yum makecache #生成缓存

yum install wget #再次测试安装软件

3.2、配置163yum源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo-aliyun-backup

vi /etc/yum.repos.d/CentOS-Base.repo #编辑源文件

[base]

name=CentOS-$releasever - Base - 163.com

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

baseurl=http://mirrors.163.com/centos-vault/7.9.2009/os/$basearch/

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates

[updates]

name=CentOS-$releasever - Updates - 163.com

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates

baseurl=http://mirrors.163.com/centos-vault/7.9.2009/updates/$basearch/

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras - 163.com

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras

baseurl=http://mirrors.163.com/centos-vault/7.9.2009/extras/$basearch/

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus - 163.com

baseurl=http://mirrors.163.com/centos-vault/7.9.2009/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

:wq! #保存退出

yum clean all

yum makecache #生成缓存

yum install wget #再次测试安装软件

3.3、配置中科大yum源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo-163-backup

vi /etc/yum.repos.d/CentOS-Base.repo #编辑源文件

[base]

name=CentOS- - Base

baseurl=https://mirrors.ustc.edu.cn/centos-vault/centos/7.9.2009/os/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[updates]

name=CentOS- - Updates

baseurl=https://mirrors.ustc.edu.cn/centos-vault/centos/7.9.2009/updates/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[extras]

name=CentOS- - Extras

baseurl=https://mirrors.ustc.edu.cn/centos-vault/centos/7.9.2009/extras/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[centosplus]

name=CentOS- - Plus

baseurl=https://mirrors.ustc.edu.cn/centos-vault/centos/7.9.2009/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

:wq! #保存退出

yum clean all

yum makecache #生成缓存

yum install wget #再次测试安装软件

至此,CentOS-7.x官方停止维护后yum源失效解决办法完成。

     

  系统运维技术交流QQ群:①185473046 系统运维技术交流□Ⅰ ②190706903 系统运维技术交流™Ⅱ ③203744115 系统运维技术交流™Ⅲ

给我留言

您必须 [ 登录 ] 才能发表留言!



Copyright© 2011-2024 系统运维 All rights reserved
版权声明:本站所有文章均为作者原创内容,如需转载,请注明出处及原文链接
陕ICP备11001040号-3