How to Fix yum Repository Issues After CentOS 7 End of Life
As of June 30, 2024, CentOS 7 has officially reached the end of its life cycle, which means it will no longer receive official support or maintenance. For users still using CentOS 7, this not only means that security updates have stopped, but also that the default yum repositories can no longer be used. If you encounter a 404 error or the message "Could not resolve host: mirrorlist.centos.org; Unknown error" when using the yum command to install or update packages, it is very likely because the yum repositories have become invalid.
To solve this problem, this article introduces several ways to switch yum repositories and provides the relevant steps to help you transition smoothly. At the same time, we also recommend replacing your operating system promptly to maintain system security and stability.
Method 1: Replace the yum configuration file
This method replaces the existing file by downloading a new repo file. The steps are simple and easy to follow.
Step 1: Use the wget command to download the new repo file
wget -O /etc/yum.repos.d/CentOS-Base.repo http://file.kangle.cccyun.cn/repo/Centos-7.repo
Or
This step downloads the new repo file to the specified directory and replaces the existing yum configuration file.
Step 2: Rebuild the yum cache
Clear the yum cache and regenerate it to ensure the new repository configuration takes effect.
Method 2: Modify the existing yum configuration file
This method directly edits the existing yum configuration file to point the yum repositories to the CentOS Vault archive.
Step 1: Comment out the existing mirrorlist configuration
This step comments out the mirrorlist entries in the yum configuration files so they no longer use the official mirror list.
Step 2: Enable baseurl and point it to CentOS Vault
This step changes the commented-out baseurl to an enabled state and points it to the CentOS Vault archive.
Step 3: Rebuild the yum cache
Clear the yum cache and regenerate it to ensure the new repository configuration takes effect.
Method 3: Edit the existing repo files
This method is similar to Method 2, but it provides more detailed and specific editing steps.
Step 1: Replace mirror.centos.org with vault.centos.org
This step replaces mirror.centos.org with vault.centos.org in all repo files.
Step 2: Enable baseurl
Change the commented-out baseurl to an enabled state.
Step 3: Comment out mirrorlist
Comment out the mirrorlist entries in all repo files.
Step 4: Rebuild the yum cache
Clear the yum cache and regenerate it to ensure the new repository configuration takes effect.
Summary
These three methods achieve the same goal, but the specific implementation process and details differ. Method 1 replaces the existing file by downloading a new repo file, making it simple and fast; Method 2 directly edits the existing file, making it flexible and easy to control; Method 3 provides more detailed editing steps, making it suitable for users with higher requirements for configuration files.
Recommendation: Replace the operating system promptly
Although switching yum repositories can allow you to continue using CentOS 7 for a while, this is only a temporary solution. Over time, using an outdated system will bring increasing security risks and compatibility issues. Therefore, we strongly recommend that you consider upgrading to a newer operating system version or migrating to another supported Linux distribution, such as Debian 12, CentOS 9 Stream, Rocky Linux, or AlmaLinux.
Switching to a supported system not only ensures that you continue to receive the latest security updates and technical support, but also keeps your system in a stable and efficient operating state. As a robust and widely popular Linux distribution, Debian 12 is a worthy option to consider. It provides long-term support and abundant software package resources, making it suitable for various server and desktop application scenarios.
We hope this blog post helps you solve the problems encountered after CentOS 7 reached end of life and provides some reference for your system upgrade. Thank you for reading!