yum: Prioritize a local repository
yum: Prioritize a local repository
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
TIA
Re: yum: Prioritize a local repository
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.
Re: yum: Prioritize a local repository
man yum.conf:
There is also https://wiki.centos.org/PackageManageme ... Priorities
I've never used that, but yum has occasionally suggested it for uncontactable repos.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.
There is also https://wiki.centos.org/PackageManageme ... Priorities
Re: yum: Prioritize a local repository
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
right now the URL of the local repository replica is in baseurl. I have to manually switch by moving the
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
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.#
Re: yum: Prioritize a local repository
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.
Another option that might work is to have both baseurl and mirrorlist active. You don't need to comment the other option out.
Re: yum: Prioritize a local repository
Yes, apparently:
And: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).
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.
[SOLVED} Re: yum: Prioritize a local repository
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
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...
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
Thanks...
-
- Posts: 2019
- Joined: 2015/02/17 15:14:33
- Location: Bulgaria
- Contact:
Re: yum: Prioritize a local repository
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.
The CentOS wiki is quite old but still valid.