0

I've noticed that YUM will seem to pick specific servers over and over when I perform yum update commands, but occasionally it'll switch and use alternative servers.

In poking around I noticed that it makes use of a plugin called yum-fastestmirror.

How does YUM and this plugin do this?

0

Background

The plugin yum-fastestmirror is really simple in concept. It simply maintains a text file with times that YUM accumulates about each mirror and then when YUM is asked to download packages, it uses the server that's shown as the fastest for the duration of the download.

The times are stored in this location:

$ locate timedhosts.txt
/var/cache/yum/x86_64/7/timedhosts.txt

If we inspect this file we'll come to find it's just hostnames with times next to each. Here we're sorting it from fastest to slowest:

$ sort -k2,2 /var/cache/yum/x86_64/7/timedhosts.txt
mirror.atlanticmetro.net 0.00165295600891
mirror.cc.columbia.edu 0.00172901153564
ewr.edge.kernel.org 0.00207901000977
mirror.es.its.nyu.edu 0.00217700004578
mirror.siena.edu 0.00543117523193
mirror.pit.teraswitch.com 0.0140120983124
mirrors.rit.edu 0.0208911895752
mirror.clarkson.edu 0.0243170261383
mirror.linux.duke.edu 0.0244128704071
mirror.mia11.us.leaseweb.net 0.0328259468079
mirror.hackingand.coffee 0.0435431003571
ftp.ussg.iu.edu 0.0479228496552
mirror.genesishosting.com 0.0481269359589
repo1.ash.innoscale.net 0.050274848938
mirror.den1.denvercolo.net 0.0838551521301
mirror.keystealth.org 0.134334802628
centos.mirror.ndchost.com 0.140916824341

Now when we inquire about a specific package's location if we were to download it using repoquery:

$ $ repoquery --location java-1.8.0-openjdk
http://mirror.atlanticmetro.net/centos/7.7.1908/updates/x86_64/Packages/java-1.8.0-openjdk-1.8.0.222.b10-1.el7_7.i686.rpm
http://mirror.atlanticmetro.net/centos/7.7.1908/updates/x86_64/Packages/java-1.8.0-openjdk-1.8.0.222.b10-1.el7_7.x86_64.rpm

Configuration

The yum-fastestmirror plugin also has its own config file:

$ more /etc/yum/pluginconf.d/fastestmirror.conf
[main]
enabled=1
verbose=0
always_print_best_host = true
socket_timeout=3
#  Relative paths are relative to the cachedir (and so works for users as well
# as root).
hostfilepath=timedhosts.txt
maxhostfileage=10
maxthreads=15
#exclude=.gov, facebook
#include_only=.nl,.de,.uk,.ie

Through this file we can instruct the plugin to whitelist & blacklist specific mirrors that have either presented us with issues in the past or we've deemed unacceptable for whatever reasons.

References

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.