Sometimes it can be handy to setup your own repository to prevent from downloading the remote repository over and over again.
Create the Directories:
mkdir -pv /var/www/html/centos/{base,updates}
Copy the RPMs from the CDs/DVD to /var/www/html/centos/base
Create the base repository headers:
createrepo /var/www/html/centos/base
Select a rsync mirror for updates:
check out this list of aviable mirrors: Centos OS Mirror list and these are identified with “rsync.” For example: “rsync://ftp.belnet.be/packages/centos/”. The mirrors share a common structure for updates. Simply append /updates/<d version>/<base arch>.
Rsync to create the updates-released repository:
rsync -avrt rsync://ftp.belnet.be/packages/centos/5.0/updates/i386 \ –exclude=debug/ /var/www/html/centos/updates
This will create a complete update repository at /var/www/html/centos/updates/i386. The repodata directory will be created with all of the headers. Next I would advise to setup a cron job to run the rsync (above). In this manner your repository keep updated and only new updates and headers will be downloaded to your repository.
Edit yum.conf:
vi /etc/yum.repos.d/CentOS-Base.repo
[base] name=CentOS-$releasever – Base baseurl=http://192.168.*.*/centos/$releasever/os/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 #released updates [updates] name=CentOS-$releasever – Updates baseurl=http://192.168.*.*/centos/$releasever/updates/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
That’s it. Special thanks to http://www.tqmcube.com for the info
July 25th, 2007 at 20:49
Are you sure this is correct? The web path to the updates is centos/updates/i386 (or x86_64). But in Centos-Base.repo it’s asking for centos/$releasever/updates/$basearch/.
Which it won’t find. Also, why is it in the [base] section rather than the [updates] section? And why do you have “Edit yum.conf:” then directly underneath have “vi /etc/yum.repos.d/CentOS-Base.repo”?
Following your instructions I’m having difficulty in getting this to work, but I’m sure after a bit of testing I’ll get there. Unless I’ve missed something in your article.
July 26th, 2007 at 20:05
I did get it running.
I don’t have that centos server available, so I can’t double check. And at the moment I didn’t find the time to setup a local server.
But I will try to look into this matter this weekend.
If you did get it working and you find that my howto is missing something let me know and I will improve my howto.
July 27th, 2007 at 00:36
Hi,
I did get it working. I’ll document what I did and forward it to you . Many thanks for taking the time to reply. This document was a great pointer in getting it working.
Thanks again,
Colin
January 20th, 2008 at 14:55
it is not work for me
when i use “yum update” i get this messge”
http://127.0.0.1/centos/5/updates/i386/repodata/repomd.xml: [Errno 14] HTTP Error 404: Not Found
i have 5.1 but it is looking for 5! why?
my path is http://127.0.0.1/centos/5.1/updates/i386/repodata/repomd.xml
January 20th, 2008 at 18:02
I think you placed the wrong link somewhere
So check all link locations or otherwise take a copy of the 5.1 directory and rename the 5.1 to 5 and test it again.
April 2nd, 2008 at 05:15
Thanks for the instructions. i’m following them for centos 5.
I ran into a little problem. When I run “yum update” the system finds a pile of updates, but then a bunch of dependancies are missing. Did I do something wrong? Could the updates need something in the base distro that was not installed, and now yum cant find the base RPMS?
April 2nd, 2008 at 23:29
Can you give me some more information on what error messages you are receiving?
April 3rd, 2008 at 09:54
@Tom – it needs to be 5, not 5.1.
Here’s a little of my CentOS-Base.repo (my repo server is called azgard):
[base]
name=CentOS-$releasever – Base
baseurl=http://azgard/repo/centos/$releasever/base/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever – Updates
baseurl=http://azgard/repo/centos/$releasever/updates/$basearch
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
The path on azgard is:
[root@azgard ~]# ls /local/repo/centos/5/
base updates
[root@azgard ~]#
I can access it using the URL http://azgard/repo – this definitely works for me.
Hope this helps
Colin
April 3rd, 2008 at 10:00
Apologies I forgot to mention about the whole 5/5.1 thing.
The underlying version of CentOS your running is 5, 5.1 is just an update to 5, which is why you have to you 5 in your repo. That caught me out when I went from 5 to 5.1
All my hosts are running 5.1, some from new, the rest upgraded using my yum repo.
April 3rd, 2008 at 21:31
@ Tom: Hope that the feedback of Colin solved your problem
@ Colin: Thanks for the perfect support.
@ Myself: need to find some time to update my tutorials