CentOS 8操作系統(tǒng)版本結(jié)束了生命周期(EOL),Linux社區(qū)已不再維護(hù)該操作系統(tǒng)版本。建議您切換到Anolis或Alinux。如果您的業(yè)務(wù)過(guò)渡期仍需要使用CentOS 8系統(tǒng)中的一些安裝包,請(qǐng)根據(jù)下文切換CentOS 8的源。
背景信息
2021年12月31日CentOS 8 EOL。按照社區(qū)規(guī)則,CentOS 8的源地址http://mirror.centos.org/centos/8/內(nèi)容已移除,目前第三方的鏡像站中均已移除CentOS 8的源。阿里云的源http://mirrors.cloud.aliyuncs.com和http://mirrors.aliyun.com也無(wú)法同步到CentOS 8的源。當(dāng)您在阿里云上繼續(xù)使用默認(rèn)配置的CentOS 8的源會(huì)發(fā)生報(bào)錯(cuò)。報(bào)錯(cuò)示例如下圖所示:

您可以通過(guò)下文的操作步驟,在CentOS 8操作系統(tǒng)的ECS實(shí)例中將源配置按照網(wǎng)絡(luò)環(huán)境不同進(jìn)行切換。
- yum源:專有網(wǎng)絡(luò)VPC類型實(shí)例需切換為
http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111源。 - epel源:專有網(wǎng)絡(luò)VPC類型實(shí)例需切換為
http://mirrors.cloud.aliyuncs.com/epel-archive/8/源。
說(shuō)明 :本文主要說(shuō)明ECS實(shí)例中的相關(guān)操作與配置。如果您的服務(wù)器不是ECS實(shí)例,需保證服務(wù)器具有公網(wǎng)訪問(wèn)能力,并且源地址
http://mirrors.cloud.aliyuncs.com需要替換為http://mirrors.aliyun.com。例如,切換yum源為http://mirrors.aliyun.com/centos-vault/8.5.2111/;切換epel源為http://mirrors.aliyun.com/epel-archive/8/。
操作步驟
登錄CentOS 8系統(tǒng)的ECS實(shí)例。具體操作,請(qǐng)參見(jiàn)連接方式概述。
-
運(yùn)行以下命令備份之前的repo文件。
rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo -
運(yùn)行以下命令下載最新的repo文件。
wget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo -
運(yùn)行以下命令替換repo文件中的鏈接。
sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo -
運(yùn)行以下命令重新創(chuàng)建緩存。
yum clean all && yum makecacheyum源和epel源切換完成后,即可使用yum install命令在實(shí)例上安裝您所需要的軟件包。