Tuesday, August 18, 2009

How-To Create A Local CentOS 5 Repository

Required Packages:

Apache web server,rsync and createrepo packages must be installed in the server before starting the whole process,

Installation Method: (Server-Side Settings)

I have used CentOS 5.3 as the base operating system, this repository is workable for CentOS 5.x versions

Login to the console as root and type the following commands

$ mkdir -p /var/www/html/centos/5/os/i386

$ mkdir -p /var/www/html/centos/5/updates/i386

than copy the whole contents of Centos 5.3 DVD in i386 directory, the createrepo.rpm must be installed in the system.

type

$ createrepo /var/www/html/centos/5/os/i386/

type

$ cp -r /var/www/html/centos/5/os/i386/* /var/www/html/centos/5/updates/i386

Now the rsync should be run in a daily cron as

$ rsync -avrt rsync://centos.arcticnetwork.ca/centos/5/updates/i386 \ --exclude=debug/ /var/www/html/centos/5/updates

This will create a complete update repository at /var/www/html/centos/5/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.

type

$ /sbin/service httpd start // to start the apache web-server

to check whether the repository is working or not.....first make sure that iptables(firewall) has a rule allowing port 80 (default apache web-server port) to be accessible, if yes, open the web-browser and type

http://server ip-address/centos/


Other rsync Centos mirrors are

rsync://mirror.csclub.uwaterloo.ca/centos/

rsync://centos.mirror.iweb.ca/centos

rsync://mirror.astate.edu/centos

rsync://linux.mirrors.es.net/linux-pub/

rsync://mirrors.kernel.org/centos/

rsync://mirror.stanford.edu/mirrors/centos/

rsync://mirror.trouble-free.net/centos/


Client-Side Settings:

On client side, rename the files present in /etc/yum.repos.d which are Centos-Base.repo and Centos-Media.repo

to *.old and create a new file named localCentos-Base.repo and copy the following in that

# vi /etc/yum.repos.d/localCentOS-Base.repo

[base]

name=CentOS-$releasever - Base

baseurl=http://ReposerverIP/centos/$releasever/os/$basearch/

gpgcheck=0


[update]

name=CentOS-$releasever - Updates

baseurl=http://ReposerverIP/centos/$releasever/updates/$basearch/

gpgcheck=0


[extras]

name=CentOS-$releasever - Extras

mirrorlist=http://ReposerverIP//centos/$releasever/updates/$basearch/

gpgcheck=0

enabled=0