centos6 系统维护到期后的软件包更新与安装问题

centos6 系统维护到期后的软件包更新与安装问题

CentOS 6 已经在 2020年11月份到期,在到期后,执行任何 yum 命令,均会提示错误。也就是说,到期后无法通过 yum 安装软件或者更新了。具体报错如下:

Loaded plugins: fastestmirror
Setting up Upgrade Process
Determining fastest mirrors
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base

如果还想执行 install 安装软件,或者 update 。总之,如果想继续使用 CentOS 6 ,则需要修改 yum 的软件源。

执行命令:

cd /etc/yum.repos.d
vim CentOS-Base.repo

也就是进入 yum 的仓库配置目录,编辑 base 文件

CentOS-Base.repo 文件中,有下列三个主要配置项

[base]
[updates]
[extras]

注释掉这三个配置项原来的的:mirrorlistbaseurl

然后再分别添加:

# 添加在 [base] 下
baseurl=https://vault.centos.org/6.10/os/$basearch/

# 添加在 [updates] 下
baseurl=https://vault.centos.org/6.10/updates/$basearch/

# 添加在 [extras] 下
baseurl=https://vault.centos.org/6.10/extras/$basearch

修改后的示例文件 (也可以把下面整段配置全部复制,替换掉 CentOS-Base.repo 文件):

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=https://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#released updates 
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=https://vault.centos.org/6.10/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
baseurl=https://vault.centos.org/6.10/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

当上面的步骤完成后,就可以正常执行 yum 命令了:

yum clean all

yum update

博客服务运行良好,根本不想去更换系统。总结就是:懒得折腾

所以暂时通过更换源,解决 yum 无法运行的问题。由于 CentOS 6 失去了安全更新等支持。如果要继续使用,要做好数据库备份等操作,等到出现了严重的安全问题,再更换系统把。

Copyright: 采用 知识共享署名4.0 国际许可协议进行许可

Links: https://zwc365.com/2020/12/25/centos6-update

Buy me a cup of coffee ☕.