YUM is a package manager used in several Linux distributions, including CentOS. It allows users to install, update, and remove packages from their systems. However, sometimes we might have multiple repositories enabled that could conflict with each other. In such cases, YUM might install a package from a less desirable repository, resulting in compatibility issues or even system crashes. To avoid such problems, we can use YUM priorities, which allows us to prioritize certain repositories over others.
In this guide, we will show you how to install and configure the yum-priorities plugin on CentOS 6.3. This plugin enables YUM to prioritize packages from specific repositories, ensuring that the most important packages are installed first.
Step 1: Install yum-priorities
The first step is to install the yum-priorities plugin. This can be done using the following command:
sudo yum install yum-plugin-priorities
[root@centos63 ~]# yum install yum-priorities -y Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfile * base: centos.ipserverone.com * extras: centos.ipserverone.com * updates: centos.ipserverone.com Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package yum-plugin-priorities.noarch 0:1.1.30-14.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================== Package Arch Version Repository Size ==================================================================================================== Installing: yum-plugin-priorities noarch 1.1.30-14.el6 base 22 k Transaction Summary ==================================================================================================== Install 1 Package(s) Total download size: 22 k Installed size: 28 k Downloading Packages: Setting up and reading Presto delta metadata Processing delta metadata Package(s) data still to download: 22 k yum-plugin-priorities-1.1.30-14.el6.noarch.rpm | 22 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : yum-plugin-priorities-1.1.30-14.el6.noarch 1/1 Verifying : yum-plugin-priorities-1.1.30-14.el6.noarch 1/1 Installed: yum-plugin-priorities.noarch 0:1.1.30-14.el6 Complete!
Step 2: Configure yum-priorities
Once the plugin is installed, we need to configure it to prioritize certain repositories over others. To do this, we need to create a configuration file called /etc/yum/pluginconf.d/priorities.conf. We can do this using the following command:
sudo vi /etc/yum/pluginconf.d/priorities.conf
This will open the Vim text editor. We need to add the following lines to the file:
[main] enabled=1 gpgcheck=1
These lines enable the plugin and specify that GPG checking should be performed for packages installed from repositories with priorities.
Step 3: Set priorities for repositories
Now that the plugin is installed and configured, we can set priorities for our repositories. We can do this by editing the repository configuration files in the /etc/yum.repos.d/ directory. For example, if we want to give priority to the base repository, we can edit the /etc/yum.repos.d/CentOS-Base.repo file and add the following lines at the end:
This sets the priority for the base repository to 1, indicating that it should be given higher priority than other repositories.
Step 4: Test yum-priorities
Once we have configured the plugin and set priorities for our repositories, we can test that everything is working as expected. We can do this by running the following command:
sudo yum update
YUM should now give priority to packages from repositories with higher priorities. If there are conflicts, YUM will choose the package from the repository with the highest priority.
- yum install – installs a package using YUM
- sudo vi – opens the Vim text editor with administrative privileges
- sudo yum update – updates all packages installed on the system
In this guide, we have shown you how to install and configure the yum-priorities plugin on CentOS 6.3. We have also demonstrated how to set priorities for repositories and test that everything is working as expected. By using yum-priorities, we can ensure that the most important packages are installed first, reducing the risk of compatibility issues or system crashes. If you have any questions or suggestions for improvements, please leave a comment below.