description
this one describes the work to setup a local repository cache (for example in a network, a server which mirrors the fedora updates repo). so all the clients load their updates from this server without downloading them from the internet (which saves internet traffic).
i know theres another way to create your own repo with 'createrepo', but we made here a similar copy (a mirror) of a repository which doesen't allows rsync...
this is the english translation out of the (german) documentation here:
http://www.liro.ch/doc/showdoc.php?d...repo_cache.inc
the howto
default repository's in fedora
by default there were three repository's enabled in fedora core linux. these are 'fedora core', 'fedora updates' and 'fedora extras'. all these repos are defined in '/etc/yum.repos.d' in a .repo file:
Code:
liro@fc5 yum.repos.d]$ ll
-rw-r--r-- 1 root root 840 Mar 15 00:20 fedora-core.repo
-rw-r--r-- 1 root root 763 Mar 15 00:20 fedora-extras.repo
-rw-r--r-- 1 root root 790 Mar 15 00:20 fedora-updates.repo
there were more repository definitions in other (and maybe inside these) files, but these three ones were enabled by default. in this howto we want to cache (or mirror) the updaes-released (fedora-updates.repo) repository. of course you can cache every repository you want...
choose a mirror
you can take a look into the .repo file, where you can find the baseurl and the mirrorlist (by default baseurl is commented out to use a mirrorlist):
Code:
[updates]
name=Fedora Core $releasever - $basearch - Updates
#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/updates/$releasever/$basearch/
mirrorlist=http://fedora.redhat.com/download/mirrors/updates-released-fc$releasever
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
'$releasever' means your fc version (in fc5 -> 5). probalby you'll get a better result with
this link (here sorted by repo and country). so choose a mirror close to you (for better download performance)...
synchronizing the choosen mirror
now we wan't to mirror a repository directory without rsync support. for this prupose we need 'lft' (if not installed, 'yum install lftp'). lftp supports a command mode, which we can use to log in to our ftp-server, navigate to our target-directory and synchronize the content.
with the following command we synchronize the switch.ch mirror (
http://mirror.switch.ch) with these options:
- transfer limit of 80kbits/s [set net:limit-rate 81920]
- first delete the local (outdated) rpms [--delete-first]
- ignore the 'debug' subdirectory [-X debug/*]
- target direcotry is '/repo_cache/updates_fc5'
- log the whole process to logfile 'fc5_repo_update.log'
Code:
lftp -c 'set net:limit-rate 81920;open mirror.switch.ch;anon;mirror --log=/repo_cache/fc5_repo_update.log --delete-first -X debug/* /mirror/fedora/linux/core/updates/5/i386/ /repo_cache/updates_fc5'
note that this is one line, without CR's. on the first attempt, this one takes realy, realy long time...(there could be a couple of GB updates...). but on the following attemtps, its done realy fast, cause only new content is downloaded...
share your repo with nfs
next step you have to do, is to setup a nfs share to your repo-data. in our example this would seem like this in '/etc/exports':
Code:
/repo_cache *(ro,sync)
connect your clients
now connect your clients to the nfs share, setup above. this can be done even static in /etc/fstab or dynamicly with automounter (autofs service). i would recommend the last option...
update your yum config
now, that you have access to your repo-data you must update your yum config. in my opinion the easiest way is to add a .repo file with the updated urls:
Code:
[cache-updates]
name=Fedora Core $releasever - $basearch - Updates
baseurl=file:///[nfs-mount-directory]/updates_fc$releasever
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
you can also copy the original 'fedora-updates.repo' to 'fedora-updates-cache.repo', but you must update the italic lines above to your needs....
important: the newly created file must even be sorted before the original fedora-updates.repo file (test with ll /etc/yum.repos.d) or you must temporarly (--disablerepo updates-released) or permanently (enabled=0 in repo-file) the fedora-updates (original). otherwise if the original repo sorts before the cache, all the updates well be download from the internet....
the result
if the original updates-released repo is still active and there are some updates on your cache they won't be downloaded from the internet, they were directly installed from your nfs-share...
Code:
[root@fc5 ~]# yum update
Loading "installonlyn" plugin
Setting up Update Process
Setting up repositories
cache-updates [1/4]
cache-updates 100% |=========================| 951 B 00:00
core [2/4]
core 100% |=========================| 1.1 kB 00:00
updates [3/4]
updates 100% |=========================| 951 B 00:00
extras [4/4]
extras 100% |=========================| 1.1 kB 00:00
...
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
kernel i686 2.6.16-1.2096_FC5 cache-updates 13 M
Updating:
beagle i386 0.2.5-1.fc5.1 cache-updates 1.3 M
gnome-pilot i386 2.0.13-7.fc5.6 cache-updates 538 k
gnome-user-share i386 0.9-4 cache-updates 37 k
libbeagle i386 0.2.5-1.fc5.1 cache-updates 35 k
procps i386 3.2.6-3.3 cache-updates 206 k
tzdata noarch 2006d-1.fc5 cache-updates 488 k
Removing:
kernel i686 2.6.15-1.2054_FC5 installed 34 M
Transaction Summary
=============================================================================
Install 3 Package(s)
Update 7 Package(s)
Remove 1 Package(s)
Total download size: 16 M
Is this ok [y/N]: y
Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
...
and as you can see the 'downloading ...' part is not seen

the packages were installed directly...