[CentOS] Question about Mirrors

Filipe Brandenburger filbranden at gmail.com
Fri Oct 10 21:22:10 UTC 2008


On Fri, Oct 10, 2008 at 17:10, Rudi Ahlers <rudiahlers at gmail.com> wrote:
> How do I actually keep a local repository on the LAN, which can be
> used by other hosts with yum & HTTP installations?
> I currently use mrepo for this purpose, but it puts everything in
> different folders, like so:

I was also using mrepo for that, but I gave up because "yum
groupinstall" does not work with it, and I also found it a little
awkward to keep multiple releases (5.1, 5.2) with it, which is
something that I want since I want to upgrade the test machines to 5.2
before I do it on the production environment.

I rolled a script that uses rsync to do that.

See this:

# Instructions on how to mirror CentOS:
# http://www.centos.org/modules/tinycontent/index.php?id=22

# MirrorList:
# http://www.centos.org/modules/tinycontent/index.php?id=13

Basically these are the commands I use:

centos_mirror=rsync.arcticnetwork.ca::centos # closest one to me, you
may want to change this

echo "===> Mirroring CentOS 5.2 (x86_64 and i386)"
rsync -azH --delete "$centos_mirror"/5.2/ \
	/var/www/mirror/centos/5.2/ \
	--include '/*/x86_64/' --include '/*/i386/' --exclude '/*/*/' \
	-v || error=yes

echo ""
echo "===> Mirroring CentOS 4.7 (x86_64 only, no isos, no cluster suite)"
rsync -azH --delete "$centos_mirror"/4.7/ \
	/var/www/mirror/centos/4.7/ \
	--include '/*/x86_64/' --exclude '/*/*/' \
	--exclude '/isos/' --exclude '/csgfs/' \
	-v || error=yes

echo ""
echo "===> Mirroring CentOS GPG keys"
rsync -azH -L "$centos_mirror"/"RPM-GPG-KEY-*" \
	/var/www/mirror/centos/ \
	-v || error=yes

I tweaked the rsync includes/excludes because I want to have CentOS 5
for both i386 and x86_64, and CentOS 4 for x86_64 only.

Then in yum.conf I comment mirrorlist= and uncomment baseurl= and
replace "mirror.centos.org" with "mirror.mydomain.net". This is the
[base] section of my CentOS-Base.repo:

name=CentOS-$releasever - Base

This is what I have in httpd.conf:

<Directory /var/www/mirror>
    Options FollowSymLinks Indexes
    AllowOverride None

<VirtualHost *:80>
	ServerName mirror.mydomain.net
	DocumentRoot /var/www/mirror
	ErrorLog logs/mirror-error_log
	CustomLog logs/mirror-access_log combined

And then I manually create the symbolic links from 5 -> 5.2 and 4 ->
4.7. When 5.3 is out, I will manually change the script to mirror it
instead of 5.2 and then change the symbolic link when I'm ready to
upgrade all the servers. It's some work, but it has to be done only
every 6 months, and it gives me the amount of control that I need.

I hope that helps! :-)


More information about the CentOS mailing list