Yum priorities: Installing Yum Priorities and Prioritizing repositories on CentOS 7

Yum Priorities are important If you have added additional third-party repositories, for example epel and remi. There can be a conflict when a version of a package is available from multiple repositories and you may end up installing the package from the least trusted source.

In this tutorial we will look at how to Priorities yum repositories by installing a plugin known as yum-plugin-priorities.

First, we need to install the yum-plugin-priorities package:

yum -y install yum-plugin-priorities

Then, open the /etc/yum/pluginconf.d/priorities.conf. Locate the enabled option and verify that its value is set to 1 to enable yum priorities.

[main]
enabled = 1

Prioritizing repositories

Now we can add a priority value for each yum repository. CentOS 7 base repository, which the most trusted source for installing packages should have high priority.

Open the /etc/yum.repos.d/CentOS-Base.repo:

vim /etc/yum.repos.d/CentOS-Base.repo

Add priority=1 under the base, updates, and extras sections. To centosplus section, add the line, priority=2:

Yum priorities: Installing Yum Priorities and Prioritizing repositories on CentOS 7

Priority numbers are in the range of 1 to 99, where 1 has the highest priority and 99 have the lowest priority.

You should add priority value to other third party repositories. You can find the configuration file for each repository under the /etc/yum.repos.d/ directory.

For example, open the /etc/yum.repos.d/epel.repo. Add priority=10 under the epel section. For the remaining sections, add the line, priority=11.

add priority value to epel repo