Hi all,
I would like to set up a local CentOS mirror, as suggested by others on this list, to cut down on bandwidth usage, etc. I have read a couple HowTos and it seems pretty straight-forward, but I do have some questions.
1) How should I change my entries in /etc/yum.repos.d? Specifically, should I replace CentOS-Base.repo with my own .repo file?
2) Is there a way to configure yum to prefer the local repo, but use an external mirror if the local is not available?
3) What is the best practice around keeping the local repo updated? A once-a-day cron job to rsync from an external mirror? If this is the correct approach, is there a way to rsync from a "mirror list" so that updates won't fail if a particular mirror happens to be unavailable when the cron job runs?
Thanks in advance for any guidance you can provide. I want to be sure I get this right!
-----Original Message----- From: centos-bounces@centos.org [mailto:centos-bounces@centos.org] On Behalf Of Art Age Software Sent: Thursday, June 26, 2008 6:03 PM To: centos@centos.org Subject: [CentOS] Starting a Local CentOS Mirror
Hi all,
I would like to set up a local CentOS mirror, as suggested by others on this list, to cut down on bandwidth usage, etc. I have read a couple HowTos and it seems pretty straight-forward, but I do have some questions.
- How should I change my entries in /etc/yum.repos.d?
Specifically, should I replace CentOS-Base.repo with my own .repo file?
I don't like fidling with files that are provided by rpms, so we use a local DNS override on the mirrors.centos.org, et al
Then we provide yum & up2date with the mirror list to choose from (1 entry our local mirror)
- Is there a way to configure yum to prefer the local repo,
but use an external mirror if the local is not available?
See above and update your returned list based on prefences.
- What is the best practice around keeping the local repo
updated? A once-a-day cron job to rsync from an external mirror?
Every ~17 hours I think we do it. We also use locks to prevent more than one from running at a time. If it fails it will try again, and delay 2x and try again, repeat...
If this is the correct approach, is there a way to rsync from a "mirror list" so that updates won't fail if a particular mirror happens to be unavailable when the cron job runs?
Hmm, don't know, might be a good idea.
Thanks in advance for any guidance you can provide. I want to be sure I get this right!
Will attach our script in reply to this message
-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - - - Jason Pyeron PD Inc. http://www.pdinc.us - - Principal Consultant 10 West 24th Street #100 - - +1 (443) 269-1555 x333 Baltimore, Maryland 21218 - - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, purge the message from your system and notify the sender immediately. Any other use of the email by you is prohibited.
[root@host67 mirrors]# cat centos.sh #!/bin/bash
lockfile=$0.lck
unset interactive unset verbose interval="20 hours" verbose="-q"
while [ "$1" != "" ] do case $1 in
--bwlimit=*) limit="--bwlimit=64" ;; --interactive) interactive=true ;; -t) interval="$2" shift ;; --prune) export prune="--delete-excluded" ;; -v) verbose="-v -v --progress" interactive=true ;; *) echo "Usage: $0" exit 1 esac
shift
done
if ( set -o noclobber; echo "$$" > "$lockfile") 2> /dev/null;
then
trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
# echo \ rsync -azH \ --delete \ rsync://mirrors.kernel.org/centos/ \ --exclude-from=centos.excludes \ $verbose \ $limit \ $prune \ centos/
rm -f "$lockfile" trap - INT TERM EXIT
if [ "$interactive" != "true" ] then
export limit export interval echo $0 | at now + 20 hours > /dev/null 2> /dev/null
fi
fi [root@host67 mirrors]# cat centos.excludes /2/ /2.1/ /3/ /3.0/ /3.1/ /3.2/ /3.3/ /3.4/ /3.5/ /3.6/ /3.7/ /3.8/ /3.9/ /5.0/ */alpha/ */s390x/ */s390/ */ia64/ */SRPMS/*.iso [root@host67 mirrors]#
-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - - - Jason Pyeron PD Inc. http://www.pdinc.us - - Principal Consultant 10 West 24th Street #100 - - +1 (443) 269-1555 x333 Baltimore, Maryland 21218 - - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, purge the message from your system and notify the sender immediately. Any other use of the email by you is prohibited.
Art Age Software wrote:
Hi all,
I would like to set up a local CentOS mirror, as suggested by others on this list, to cut down on bandwidth usage, etc. I have read a couple HowTos and it seems pretty straight-forward, but I do have some questions.
- How should I change my entries in /etc/yum.repos.d? Specifically,
should I replace CentOS-Base.repo with my own .repo file?
You probably need to edit your CentOS-Base.repo file. See my suggested way in the answer to your next question.
- Is there a way to configure yum to prefer the local repo, but use
an external mirror if the local is not available?
Yes
You can just add one baseurl=<local_path> line to your CentOS-Base.repo file for each section ([base], [updates], etc.) ... while still leaving the "mirrorlist=" one enabled. Then install the yum-fastestmirror plugin ... fastest mirror SHOULD always pick your local mirror, and if it is not available it should pick the next fastest one listed.
- What is the best practice around keeping the local repo updated? A
once-a-day cron job to rsync from an external mirror? If this is the correct approach, is there a way to rsync from a "mirror list" so that updates won't fail if a particular mirror happens to be unavailable when the cron job runs?
We do not provide public syncs from our infrastructure except for "public mirrors" (people who are allowing public access to their mirrors) ... however, there are about 200 public mirrors, some of which provide rsync. Here is the list of public mirrors:
http://www.centos.org/modules/tinycontent/index.php?id=13
Thanks, Johnny Hughes