How to Install and Configure yum-priorities on RHEL 6/CentOS 6

In this post, i will show on how to install and configure yum-priorities on CentOS 6 or RHEL 6 Linux server. Theoretically, the repositories with the lowest numerical priority number have the highest priority. This is one of the method to prevents mistakes such as accidentally running yum upgrade with everything. This steps has been tested on CentOS 6.2, but it may working on CentOS 6.0, CentOS 6.1 and RHEL 6 server.

1. To Install the yum-priorities, simply run this command :

[root@centos62 ~]# yum install yum-priorities -y

Example :

[root@centos62 ~]# yum install yum-priorities -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * remi:
 * remi-test:
 * rpmforge:
 * updates:
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package yum-plugin-priorities.noarch 0:1.1.30-10.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

 Package                          Arch              Version                   Repository       Size
 yum-plugin-priorities            noarch            1.1.30-10.el6             base             22 k

Transaction Summary
Install       1 Package(s)

Total download size: 22 k
Installed size: 28 k
Downloading Packages:
yum-plugin-priorities-1.1.30-10.el6.noarch.rpm                               |  22 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : yum-plugin-priorities-1.1.30-10.el6.noarch                                       1/1

  yum-plugin-priorities.noarch 0:1.1.30-10.el6


2. After the plugin is installed, make sure that it is enabled on /etc/yum/pluginconf.d/priorities.conf file.

[root@centos62 ~]# more /etc/yum/pluginconf.d/priorities.conf
enabled = 1

If “enabled” value = 0, you can enable it using vi editor and set it to 1.

3. With the plugin enabled, you may add priorities to the target repositories by adding the following line :


Where N is an integer from 1 to 99. The lower the number the more important it is, so CentOS-Base.repo must always the lowest.

[root@centos62 ~]# vi /etc/yum.repos.d/CentOS-Base.repo

Add this line on base repo :

priority = 1

Example :

# CentOS-Base.repo
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.


name=CentOS-$releasever - Base mirrorlist=$releasever&arch=$basearch&repo=os #baseurl=$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 priority = 1 #released updates


name=CentOS-$releasever - Updates mirrorlist=$releasever&arch=$basearch&repo=updates #baseurl=$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful


name=CentOS-$releasever - Extras mirrorlist=$releasever&arch=$basearch&repo=extras #baseurl=$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages


name=CentOS-$releasever - Plus mirrorlist=$releasever&arch=$basearch&repo=centosplus #baseurl=$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users


name=CentOS-$releasever - Contrib mirrorlist=$releasever&arch=$basearch&repo=contrib #baseurl=$releasever/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 -- INSERT --

4. As an example, another 3rd party repository is Remi. Follow this steps to Add the Remi Repository on CentOS 6/RHEL 6 Linux Server :
Open the Remi configuration file and insert “priority = 5” after “enabled = 1” in the [remi] section :

[root@centos62 ~]# vi /etc/yum.repos.d/remi.repo

Example :

name=Les RPM de remi pour Enterprise Linux $releasever - $basearch
priority = 5


name=Les RPM de remi en test pour Enterprise Linux $releasever – $basearch #baseurl=$releasever/test/$basearch/ mirrorlist=$releasever/test/mirror enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi