yum: Prioritize a local repository

Issues related to applications and software problems
Post Reply
tedlum
Posts: 47
Joined: 2007/07/23 21:53:43

yum: Prioritize a local repository

Post by tedlum » 2018/09/05 13:41:04

I have a local CentOS repository. Laptops roam however so the local repository is not always local, or even accessible, to them. Is it possible to configure yum to use the local repository when it's reachable, and fall back to the public pool when it's not?

TIA

User avatar
avij
Retired Moderator
Posts: 3046
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: yum: Prioritize a local repository

Post by avij » 2018/09/05 14:58:51

All other things being equal, yum gives priority to those repositories with the shortest names. My local repos are named "b", "u" and "e" for this reason.

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: yum: Prioritize a local repository

Post by jlehtone » 2018/09/05 22:00:36

man yum.conf:
skip_if_unavailable If set to True yum will continue running if this repository cannot be contacted for any reason. This should be set carefully as all repos are consulted for any given command. Defaults to False.
I've never used that, but yum has occasionally suggested it for uncontactable repos.


There is also https://wiki.centos.org/PackageManageme ... Priorities

tedlum
Posts: 47
Joined: 2007/07/23 21:53:43

Re: yum: Prioritize a local repository

Post by tedlum » 2018/09/06 05:04:03

Oops, i should have been more specific. I'm not referring to different repositories, I'm referring to different instances of the SAME repository.

For example

Code: Select all

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://192.168.4.14/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
right now the URL of the local repository replica is in baseurl. I have to manually switch by moving the
#
from baseurl to mirrorlist. What I want is to always try 192.168.4.14 first, but if it fails, then use the public mirror list.

User avatar
avij
Retired Moderator
Posts: 3046
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: yum: Prioritize a local repository

Post by avij » 2018/09/06 05:11:53

You can have the unmodified CentOS-Base.repo pointing to mirrorlist, and your own mymirror.repo with different repository names (like b, u, e) pointing to somewhere else. That skip_if_unavailable suggestion above is also a good idea for your own copy of the repository.

Another option that might work is to have both baseurl and mirrorlist active. You don't need to comment the other option out.

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: yum: Prioritize a local repository

Post by jlehtone » 2018/09/06 08:22:52

Yes, apparently:
mirrorlist Specifies a URL to a file containing a list of baseurls. This can be used instead of or with the baseurl option. Substitution variables, described below, can be used with this option. As a special hack is the mirrorlist URL contains the word "metalink" then the value of mirrorlist is copied to metalink (if metalink is not set).
And:
failovermethod Either `roundrobin' or `priority'.

`roundrobin' randomly selects a URL out of the list of URLs to start with and proceeds through each of them as it encounters a failure contacting the host.

`priority' starts from the first baseurl listed and reads through them sequentially.

failovermethod defaults to `roundrobin' if not specified.

tedlum
Posts: 47
Joined: 2007/07/23 21:53:43

[SOLVED} Re: yum: Prioritize a local repository

Post by tedlum » 2018/09/06 13:19:36

It's been a long time since I messed with this, so my memory of baseurl and mirrorlist functioning as expected and desired is a bit fuzzy so I decided to test it again as follows

Code: Select all

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://192.168.4.14/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
and it does use baseurl when it's available, and goes to mirrorlist when it's not, which is what I expected and also exactly what is desirable. My fuzzy recollection was that it would often skip the baseurl even when it was available, but that experience was so long ago we're probably talking version 5 or 6. I don't know if something has changed, or I just got it wrong to begin with, but with v7 I think I'm getting what I need this way... until it proves me wrong in practice, so we'll see.

Thanks...

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: yum: Prioritize a local repository

Post by hunter86_bg » 2018/09/06 19:45:01

There is a plugin for yum called "yum-plugin-priorities" which with some modification in the repos, can prioritize a repo over another repos.
The CentOS wiki is quite old but still valid.

Post Reply