How to switch the image source after CentOS8 ends its life cycle
An alternative source is officially provided, but no more updates, only packages.
The CentOS8 system recommends using Alibaba Cloud's image source in China. The specific switching process is as follows:
# 备份现有的repo配置文件
rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
yum clean all && yum makecache
For Alibaba Cloud ECS users, the following image sources can be used:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.aliyuncs.com/repo/Centos-vault-8.5.2111.repo
sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g' /etc/yum.repos.d/CentOS-Base.repo && sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/CentOS-Base.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/CentOS-Base.repo
yum clean all && yum makecache
For foreign users, you can use the Vault mirror source provided by the official website
add epel source
Similarly, domestic users can replace the epel source provided by Alibaba Cloud.
# 使用安装包添加
rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
# 或者直接手工添加
cat <<END > /etc/yum.repos.d/CentOS-epel.repo
baseurl=http://mirrors.aliyun.com/epel/8/Everything/\$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
END
yum clean all && yum makecache
In this way, we can successfully update the epel source.
at last
The above is the image source switching method of CentOS8, as for other versions, only need to change the version number to apply.
It is worth mentioning that changing the mirror source is only a temporary alternative, and the future solution can only be to change to other distributions, such as AlmaLinux/CentOS Stream/RockyLinux/Ubuntu/Debian, etc.
Of course, if your server is only used for some simple applications, there is no need to bother. After all, the cost of migration is also very high, and it is not worth the loss if you accidentally lose it.