Wednesday, June 27, 2018

How to Fix Duplicate Packages in YUM on CentOS 7


Overview

In this guide we will go through the steps of resolving “YUM”, sometimes yum encounters errors, it can cause RPMDB (database) as inconsistent, duplicate packages are installed, because yum cleanup and verification process is incomplete, which could be possibly that YUM process is killed or terminated abruptly.

Applies To

CentOS 7.1.1503 (Core), tested on CentOS 7.x (minimal install)

Pre-Requisites

  1. Internet connection to fetch and install packages.
  2. DHCP or static IP Address enabled or assigned host.
  3. sudo or root access to the host.

Error Message

When you execute “YUM” to update or install a package, you could get following error message and yum process gets ended automatically without completing the task that it was intended to perform i.e., when you try to install or upgrade a package.

Error Message – Cause

One of the main causes of rpmdb inconsistency, when yum is process terminated or killed abruptly;


Resolution

In order to resolve this issue, YUM Utils package has to be installed, which can identify duplicate packages that are installed on the server and subsequently remove those packages with this utility commands.

Install Package – Yum Utils

To resolve the issue, we have to first install “yum-utils” package, to install package run the command;

yum install -y yum-utils -q




Verify Package – Yum Utils

yum list installed | grep yum-utils 



Duplicate Packages – List

After installation of utility, to list duplicate packages installed on the server, run the command;

package-cleanup --dupes -q | head -5




Duplicate Packages – Count

Additionally, you could count duplicate packages installed on the server, though this command is for information only, run the command;

package-cleanup --dupes -q | wc -l



Duplicate Packages – Packages

As an example, when the command is executed, you can view the duplicate packages, as shown below; in this example python-urlgrabber has two versions installed on the server.



Duplicate Packages – Clean Duplicates

As shown earlier in order to remove duplicate packages installed on the server package-cleanup command with “--cleandupes” argument will allow help us in removing duplicate packages installed on the server, run the command;

package-cleanup --cleandupes






Remove Packages - Manually

There are few instances wherein few packages that are not removed with this utility, you could remove manually with yum erase command, for example;

yum erase <Package Name>

or

yum erase zlib-1.2.7-17.el7.x86_64


Duplicate Packages – Removal Validation

Once you have resolved / removed all the duplicate packages, if you run the command again, below message will be displayed i.e., “No Problems Found”.

package-cleanup --dupes -q


package-cleanup --problems -q




Sideshare Information

A step by step guide along with screenshots is uploaded to slideshare.




No comments:

Post a Comment