Why must yum update its repos on each command?

skyler asked:

Doing anything with yum is frustratingly slow for me. For example, when searching for a package, finding it, and then trying to install it, both yum commands appear to run the exact same updates, just seconds apart!

What can I do to speed this up?

(oldcfft)~/workspace/panel (live)> yum search bz2
Loaded plugins: fastestmirror, presto
Determining fastest mirrors
epel/metalink                                                                               |  14 kB     00:00
 * base: mirror.5ninesolutions.com
 * epel: mirror.metrocast.net
 * extras: centos.unmeteredvps.net
 * updates: mirrors-pa.sioru.com
10gen                                                                                       |  951 B     00:00
10gen/primary                                                                               |  12 kB     00:00
10gen                                                                                                      105/105
base                                                                                        | 3.7 kB     00:00
base/primary_db                                                                             | 4.4 MB     00:09
epel                                                                                        | 4.2 kB     00:00
epel/primary_db                                                                             | 5.5 MB     00:13
extras                                                                                      | 3.4 kB     00:00
extras/primary_db                                                                           |  18 kB     00:00
nginx                                                                                       | 2.9 kB     00:00
nginx/primary_db                                                                            |  24 kB     00:00
pgdg91                                                                                      | 2.8 kB     00:00
pgdg91/primary_db                                                                           | 123 kB     00:00
pgdg92                                                                                      | 2.8 kB     00:00
pgdg92/primary_db                                                                           | 112 kB     00:00
updates                                                                                     | 3.4 kB     00:00
updates/primary_db                                                                          | 4.4 MB     00:15
epel/pkgtags                                                                                | 588 kB     00:01
======================================================================== N/S Matched: bz2 =========================
bzip2.x86_64 : A file compression utility

  Name and summary matches only, use "search all" for everything.
(oldcfft)~/workspace/panel (live)> sudo yum install -y bzip2
Loaded plugins: fastestmirror, presto
Determining fastest mirrors
epel/metalink                                                                               |  14 kB     00:00
 * base: mirror.es.its.nyu.edu
 * epel: mirror.us.leaseweb.net
 * extras: centos.unmeteredvps.net
 * updates: mirrors-pa.sioru.com
10gen                                                                                       |  951 B     00:00
10gen/primary                                                                               |  12 kB     00:00
10gen                                                                                                      105/105
base                                                                                        | 3.7 kB     00:00
epel                                                                                        | 4.2 kB     00:00
epel/primary_db                                                                             | 5.5 MB     00:15
extras                                                                                      | 3.4 kB     00:00
nginx                                                                                       | 2.9 kB     00:00
nginx/primary_db                                                                            |  24 kB     00:00
pgdg91                                                                                      | 2.8 kB     00:00
pgdg91/primary_db                                                                           | 123 kB     00:00
pgdg92                                                                                      | 2.8 kB     00:00
pgdg92/primary_db                                                                           | 112 kB     00:00
updates                                                                                     | 3.4 kB     00:00
updates/primary_db                                                                          | 4.4 MB     00:10
Setting up Install Process
Package bzip2-1.0.5-7.el6_0.x86_64 already installed and latest version
Nothing to do

My answer:


You first ran yum search as a normal user, and then later ran it as root (with sudo).

The invocation as root stores its cache data in /var/cache/yum, which is not writable to normal users. So, when you ran it as your own user account, it had to be downloaded again and stored in another temporary directory.

To resolve this issue, always run yum in a root shell, or with sudo.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.