How to Install and Configure yum-priorities on CentOS 5/RHEL 5 Linux Server

In this post, i will show on how to install and configure yum-priorities on CentOS 5 or RHEL 5 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 5.7, but it may working on CentOS 5.1, CentOS 5.2, CentOS 5.4, CentOS 5.5, CentOS 5.6 and RHEL 5.

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

[root@CentOS57 ~]# yum install yum-priorities -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * extras:
 * rpmforge:
 * updates:
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package yum-priorities.noarch 0:1.1.16-21.el5.centos set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

 Package                   Arch              Version                          Repository       Size
 yum-priorities            noarch            1.1.16-21.el5.centos             base             16 k

Transaction Summary
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 16 k
Downloading Packages:
yum-priorities-1.1.16-21.el5.centos.noarch.rpm                               |  16 kB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : yum-priorities                                                               1/1

  yum-priorities.noarch 0:1.1.16-21.el5.centos


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

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

If enabled = 0, you can enabled it using vi editor as below :

[root@CentOS57 ~]# vi /etc/yum/pluginconf.d/priorities.conf

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@CentOS57 ~]# vi /etc/yum.repos.d/CentOS-Base.repo

Add this line on base repo :

priority = 1
# 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
priority = 1

#released updates
name=CentOS-$releasever - Updates

#additional packages that may be useful
name=CentOS-$releasever - Extras

#additional packages that extend functionality of existing packages
name=CentOS-$releasever - Plus

#contrib - packages by Centos Users
name=CentOS-$releasever - Contrib

4. As an example, another 3rd party repository is RPMforge. Follow this steps to Add the RPMforge Repository on CentOS 5/RHEL 5 Linux Server :
How to Add the RPMforge Repository on CentOS 5/RHEL 5 Linux Server

See also  How to Setup Local Yum Repository from CD-ROM/DVD-ROM image on Fedora 16

Open the RPMforge configuration file and insert “priority = 5” after “enabled = 1” in the [rpmforge] section :

[root@CentOS57 ~]# vi /etc/yum.repos.d/rpmforge.repo

In this case, i will add the fifth highest possible priority which is “priority=5” :

### Name: RPMforge RPM Repository for RHEL 5 - dag
### URL:
name = RHEL $releasever - - dag
baseurl =$basearch/rpmforge
mirrorlist =
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
priority = 5
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1

name = RHEL $releasever - - extras
baseurl =$basearch/extras
mirrorlist =
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge-extras
enabled = 0
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1

name = RHEL $releasever - - testing
baseurl =$basearch/testing
mirrorlist =
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge-testing
enabled = 0
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1


Leave a Reply

Your email address will not be published. Required fields are marked *