From: http://joshua14.homelinux.org/blog/?p=1094

If you have many Fedora (or any Red Hat based) systems, updating them all via yum separately means that you’re going to be downloading an awful lot of duplicated updates. Also, in some organisations, they will have a local yum repository for officially sanctioned updates so that it doesn’t break bespoke software that relies on specific versions of software packages. Here I’ll show you how to create your own local yum repository on your network via the Apache web server which you can then use for all the machines on your network – the point being that the updates are downloaded from a master server only once, thus saving you time and bandwidth.

First off, you’ll need to make you you have the Apache web server installed and running on the server you want to use as a yum repository. If it is, you can skip to the next part. If not or you’re not sure, install it with: –

yum install httpd

Set the httpd daemon to run with:-

service httpd start

This assumes that you now have your HTML document root at “/var/www/html”, which is the default. Also, if you have a firewall like iptables running you’ll need to open port 80 to allow HTTP traffic through.

iptables -A INPUT -p tcp --dport 80 -j ACCEPT

You can verify the port is open with:-

iptables -L

which should show you something like:-

ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http

The next thing to do is to create the directory structure required by yum to hold the packages. Create the following directories with:-

mkdir /var/www/html/yum
mkdir /var/www/html/yum/base
mkdir /var/www/html/yum/updates

You’ll also need your Fedora installation CD for this next part. We’re going to copy the all the installation packages over. You can either use an installation CD/DVD or you can simply mount the ISO file you no doubt downloaded from the Fedora website. If you want to mount the ISO file, you can use:-

mount -o loop -t iso9660 /path/to/your/iso/file /mnt/iso

This will mount your ISO image at the /mnt/iso mount point directory – although the iso sub-directory must exist first, obviously. If not, create it.

The packages you want will be under “Packages” on the CD/DVD or mount point, so copy them to the “/var/www/html/yum/base” sub-directory you created earlier. Assuming you’re using a mount point of “/mnt/iso”, you’d use:-

cp /mnt/iso/Packages/* /var/www/html/yum/base

Next you need to create the base repository headers. For this, you’ll need a small utility called “createrepo”. It’s usually installed by default under Fedora, but if you’re using another Red Hat based distribution or it isn’t installed, install it with:-

yum install createrepo

After that, run:-

createrepo /var/www/html/yum/base

This may take some time, depending on your system hardware specifications, but eventually you should end up with a sub-directory from there called “repodata”. If you do an “ls” on that directory, you should see files that look something like the following:-

primary.sqlite.bz2
primary.xml.gz
other.sqlite.bz2
filelists.xml.gz
other.xml.gz
filelists.sqlite.bz2
repomd.xml

These are your repository header files. Okay, now you need to select an external mirror site for all the Fedora update packages. We’re going to use rsync (which I’ve covered before to sync backups across servers) to sync our local repository to an externally maintained Fedora repository. You can find a list of public mirror sites for your country and Fedora version hereMake sure the mirror site you choose supports rsync and not just HTTP or FTP else the following won’t work and you’ll have to use something like the “wget” command to copy over all the updated packages. Clearly “rsync” is better in this situation. For the sake of this post, I’m going to assume you’re in the United Kingdom and are using Fedora 15 on 64-bit systems. To sync your repository with the example one based on the above requirements, I’d use the command:-

rsync -av rsync://mirror.bytemark.co.uk/fedora/linux/updates/15/x86_64/ -exclude=debug/ /var/www/html/yum/updates

This example is using rsync to sync our local yum update directory with a Fedora mirror site maintained by Bytemark in the UK for 64-bit Fedora systems. Now would be a good time to create a daily cron job to keep your local repository in sync with the external one, so enter your crontab with:-

crontab -e

and add the following line (or whatever you want, assuming you’re familiar with using cron jobs):-

0 0 * * * rsync -av --delete rsync://mirror.bytemark.co.uk/fedora/linux/updates/15/x86_64/ -exclude=debug/ /var/www/html/yum/upates

Save this by typing “:wq” This will update your repository every night at midnight. I’ve also added the delete flag in order to save space so that source and destination match. Use “man rsync” if you want more information on this.

Lastly you’ll need to configure yum on your servers that you want to be updated via yum to point to your new yum update repository. While you can add this to “/etc/yum.conf”, it’s recommended that you add a separate .repo file under “/etc/yum.repos.d”. So create a new .repo file with:-

vi /etc/yum.repos.d/myupdateserver.repo

and add the following information:-

[updates-released]
name=Fedora Released Updates
baseurl=http://192.168.1.3/yum/updates
enabled=1
gpgcheck=1
[base]
name=Fedora - Base
baseurl=http://192.168.1.3/yum/base
enabled=1
gpgcheck=1

If you want to use environment variables to get the Fedora version and architecture, see here. Replace the “192.168.1.3″ IP address with the IP address of your repository server. That’s it – add this file to each Fedora server you want to update locally and you’re good to go :-)

 846 total views

If you’re a Star Trek fan, you’ve no doubt heard the story of how Dr. Martin Luther King Jr. persuaded Nichelle Nichols to remain on the original series as Lt. Uhura when she was thinking of leaving after the first season.


 712 total views