Linux:How to configure centralized yum repo server (Centos)

Local yum repository is used for local network and to make sure that all your server has same rpm for benchmarking and patching purpose.Its also save bandwidth because all the rpm will be store in one server(Central Repo Server) and rest of the servers will install those rpm from local repo server. Hence they don’t have to download from public server.

For Creating Central Repo server, you will need a Apache server .

In our organization I have created Yum server directory under (Its for 64 bit server)
/usr/local/apache/htdocs/install/centos64/
But you can chose any Directory .

    Building the Base Repository:

Step 1 :# Copy all content from CD/DVD to Repository Directory

Copy all the files and directory from Centos 5.5 DVD or CD into /usr/local/apache/htdocs/install/centos64/
So your directory should look like bellow

[root@controlserver1 centos64]# ls
CentOS                 RELEASE-NOTES-de.html     RELEASE-NOTES-nl
EULA                   RELEASE-NOTES-en          RELEASE-NOTES-nl.html
GPL                    RELEASE-NOTES-en.html     RELEASE-NOTES-pt_BR
images                 RELEASE-NOTES-en_US       RELEASE-NOTES-pt_BR.html
isolinux               RELEASE-NOTES-en_US.html  RELEASE-NOTES-ro
kicks                  RELEASE-NOTES-es          RELEASE-NOTES-ro.html
ks.cfg                 RELEASE-NOTES-es.html     repodata
NOTES                  RELEASE-NOTES-fr          RPM-GPG-KEY-beta
RELEASE-NOTES-cs       RELEASE-NOTES-fr.html     RPM-GPG-KEY-CentOS-5
RELEASE-NOTES-cs.html  RELEASE-NOTES-ja          TRANS.TBL
RELEASE-NOTES-de       RELEASE-NOTES-ja.html

As you can see Centos Directory has all the rpm , So I decided to make Centos directory as my Centralized yum directory.

For Centralized yum repository , I need to create rpm headers for base repository , so execute bellow command

Step 2: Create the base repository headers

createrepo /usr/local/apache/htdocs/install/centos64/CentOS

Upper command will create repodata directory under Centos directory
the directory should be like bellow :

[root@controlserver1 CentOS]# cd repodata/
[root@controlserver1 repodata]# pwd
/usr/local/apache/htdocs/install/centos64/CentOS/repodata
[root@controlserver1 repodata]# ls -al
total 14252
drwxr-xr-x 2 root root    4096 Nov 26 15:20 .
drwxr-xr-x 3 root root  221184 Nov 26 15:20 ..
-rw-r--r-- 1 root root 3373682 Nov 26 15:20 filelists.xml.gz
-rw-r--r-- 1 root root 9813890 Nov 26 15:20 other.xml.gz
-rw-r--r-- 1 root root 1144150 Nov 26 15:20 primary.xml.gz
-rw-r--r-- 1 root root     951 Nov 26 15:20 repomd.xml
[root@controlserver1 repodata]#

Building repository for updating yum packages

Step 3: Create a directory call updates

[root@controlserver1 centos64]# pwd
/usr/local/apache/htdocs/install/centos64
[root@controlserver1 centos64]# mkdir updates

So it should be like this

[root@controlserver1 centos64]# pwd
/usr/local/apache/htdocs/install/centos64
[root@controlserver1 centos64]# ls
CentOS                 RELEASE-NOTES-de.html     RELEASE-NOTES-nl
EULA                   RELEASE-NOTES-en          RELEASE-NOTES-nl.html
GPL                    RELEASE-NOTES-en.html     RELEASE-NOTES-pt_BR
images                 RELEASE-NOTES-en_US       RELEASE-NOTES-pt_BR.html
isolinux               RELEASE-NOTES-en_US.html  RELEASE-NOTES-ro
kicks                  RELEASE-NOTES-es          RELEASE-NOTES-ro.html
ks.cfg                 RELEASE-NOTES-es.html     repodata
NOTES                  RELEASE-NOTES-fr          RPM-GPG-KEY-beta
RELEASE-NOTES-cs       RELEASE-NOTES-fr.html     RPM-GPG-KEY-CentOS-5
RELEASE-NOTES-cs.html  RELEASE-NOTES-ja          TRANS.TBL
RELEASE-NOTES-de       RELEASE-NOTES-ja.html     updates

Step 4: Select an rsync mirror to upload
Select any mirror from here:
http://www.centos.org/modules/tinycontent/index.php?id=31

Step 5 : Rsync the updates-released repository

 rsync -avrt rsync://rsync.mirrorservice.org/mirror.centos.org/5.5/updates/x86_64/RPMS/ --exclude=debug/ /usr/local/apache/htdocs/install/centos64/updates/

It will download all the rpms from listed website into my updates directory.

Step 6: Rsync the repodata from

Go into updates directory and download all the contents from repodata.

[root@controlserver1 updates]# pwd
/usr/local/apache/htdocs/install/centos64/updates
[root@controlserver1 updates]#
 
rsync -avrt rsync://rsync.mirrorservice.org/mirror.centos.org/5.5/updates/x86_64/repodata --exclude=debug/ /usr/local/apache/htdocs/install/centos64/updates/

Step 7:Edit yum.conf

Create a repo file under your : /etc/yum.repos.d directory.

[root@mysqlcluster2 yum.repos.d]# pwd
/etc/yum.repos.d
[root@mysqlcluster2 yum.repos.d]# ls
CentOS-Base.repo CentOS-Media.repo local.repo
[root@mysqlcluster2 yum.repos.d]

And disable other repos by inserting enabled=0 , Example :
[centosplus]
name=CentOS-$releasever – Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

Insert the bellow lines into local.repo files

[base-local]
name=Centos $releasever - $basearch
failovermethod=priority
baseurl=http://10.0.0.55/centos64/CentOS/
enabled=1
gpgcheck=0
 
[updates-local]
name=Centos $releasever - $basearch - Updates
failovermethod=priority
baseurl=http://10.0.0.55/centos64/updates/
enabled=1
gpgcheck=0

Now try yum command

 yum clean all
Loaded plugins: fastestmirror
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@mysqlcluster2 /]# yum update
Loaded plugins: fastestmirror
Determining fastest mirrors
base-local                                               |  951 B     00:00
base-local/primary                                       | 1.1 MB     00:00
base-local                                                            3186/3186
updates-local                                            | 1.9 kB     00:00
updates-local/primary_db                                 | 1.0 MB     00:00
Setting up Update Process

Centralized Local repository is done!!..

Tags: , , , ,

Leave a Reply

*