In this process, we will investigate the role of YUM with regard to ensuring that the working cache remains current. As a part of its typical mode of operation, YUM will create a cache that consists of metadata and packages. These files are very useful, but over time, they will accumulate in size to such an extent that you may find that YUM is acting erratically or not as intended. The frequency of this happening can vary from system to system, but it generally implies that the YUM cache system requires your immediate attention. Such a situation can be quite frustrating, but it is the purpose of this process to provide a quick solution that will serve to assist you in cleaning the cache and restoring
YUM to its original working state.
To Start With: What Do You Need?
To complete this process, you will require a working installation of the CentOS 7 operating system with root privileges, a console-based text editor of your choice, and a connection to the Internet in order to facilitate the download of additional packages.
The Process:
Before we begin, it is important to realize that, while we are troubleshooting a current problem, this same process can be run as often as required in order to keep YUM in an optimal working state:
- We will begin this process by asking YUM to clean any cached package information. To do this, log in as root and type the following:
yum clean packages
- Allow time for your system to respond and when finished, type the following command to remove any cached XML-based metadata:
yum clean metadata
- Again, wait for YUM to respond and when ready, type the following command to remove any cached database files:
yum clean dbcache
- Following this, you will want to clean all the files to confirm the preceding instructions and to ensure that unnecessary disk space is not used. To do this, type the following line:
yum clean all
- Finally, you will want to rebuild the YUM cache by typing what is shown next:
yum makecache
How Does It Work?
YUM is a very powerful tool that is known for its ability to resolve package dependencies and automate the process of package management, but as with all things, there are times when even the best utilities can get confused and may report errors or behave erratically.
Fixing this issue is relatively simple and the approach outlined in this process will also serve to keep your package manager in a healthy running state for the life of your operating system.
So, what have we learned from this experience?
During its typical operation, YUM will create a cache of metadata and packages that can be found at /var/cache/yum. These files are essential, but as they grow in size, this cache will ultimately serve to slow down the overall use of this utility and may even cause some issues. To address this situation, we started by using the following command to clean the current package-based cache using YUM’s clean packages parameter options. We then followed this by cleaning the metadata cache using the command clean metadata, which will remove any excess XML-based files. YUM uses a SQLite database as a part of its normal operation, so the next step was to remove any remaining database files using the clean dbcache parameters. The next step was to clean all files associated with enabled repositories in order to reclaim any unused disk space: yum clean all. Finally, we restored YUM to its normal working state by rebuilding the cache using the makecache option.
There’s More:
On a typical server, YUM is a great tool that will solve the most complex problems related to package dependencies and package management. However, in instances where you have knowingly mixed incompatible repositories or have used incomplete sources, there is a risk that YUM will not be able to help.
Note
Remember, in this situation, you should consider the following advice to be a temporary remedy only. A tendency to ignore any warnings provided by YUM will only lead to bigger problems later on.
If such instances occur, and if the error is RPM-based, as a temporary fix, you can skip broken packages by using the following command:
yum -y update --skip-broken
This command will allow YUM to continue working by bypassing any packages with errors, but as stated earlier this should be regarded as a temporary fix only. You should always be aware that a system with broken dependencies is not considered to be a healthy system. This situation is to be avoided at all costs, and under these circumstances fixing such errors should become your first priority.