Yum Update Not Working on Centos 7
Publisher: Psychz Networks, January 23,2019It seems that the 'yum update' is causing some issue when you try to run an update. The YUM allows you to easily install, update, remove or search software packages on a system.
At this point, the yum update must be failing for many reasons and to identify the issue it is important to have the error message for reference.
Some of the most common error messages are
and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail.
Or
Reason
It is highly like that the standard CentOS repository files are missing in the /etc/yum.repos.d/ directory. The easiest way to fix these repositories is to reinstall centos release packages. In the following given steps, we will attempt to do so on a CentOS 7.
Note: Following steps will work on CentOS 6 or CentOS 7
Step 1
Connect to your server as root via SSH
Step 2
We will remove existing centos-release
# rpm -e centos-release --
nodeps
Info: The --nodeps option allows RPM to continue installing despite the fact that you are missing a handful of packages that $package depends on. Using it with rpm -e command, the package will be erased without giving you warning, even if some other packages are dependent on the package you are trying to erase.
Step 3
Download the necessary package from CentOS 7 Repository http://mirror.centos.org/centos/7/os/x86_64/Packages/
Tip: You can use your browser search option (Ctrl + f) and type 'centos-release' to locate the file to download.
Step 4
Install the package. You can do this either by directly accessing the file from CentOS repository
# rpm -Uvh http://mirror.centos.org/centos/7/os/x86_64/Packages/centos-release-7-5.1804.el7.centos.x86_64.rpm
Or
If you have downloaded the file on your local system, you need to run following
# rpm -Uvh /home/user/Downloads/
centos-release
-7-5.1804.el7.centos.x86_64.rpm
Info
v - verbose (using or expressed in more words than are needed)
h - hash (Print 50 hash marks as the package archive is unpacked)
U(caps) - upgrade (This upgrades or installs the package currently installed to a newer version. This is the same as install, except all other version(s) of the package are removed after the new package is installed)
This should update the repository and files, and fix the problem. You can now run the command that you were trying to earlier and give it a shot.