Creating a Yum Repository Server for Red Hat and CentOS

There are many reasons you may want a local Red Hat Enterprise Linux or Centos repository. Bandwidth is a major factor as downloading updates from the Internet can be time and bandwidth consuming. Another reason may be that your servers are not connected to the Internet and thus need to get their updates from a local source. You may have a development environment that you would prefer to not spend money on licenses for but still need to update. Whatever your reason, this tutorial will walk you through the process of getting your local repository setup.

Firslty ,you have to install below packages.

yum install yum-utils createrepo httpd

mkdir /var/www/html/rhel7

reposync –gpgcheck -l –repoid=rhel-7-for-power-rpms –download_path=/var/www/html/rhel7 –downloadcomps –download-metadata

Once the packages have been downloaded all that is needed is the createrepo command below for each repo.

createrepo /var/www/html/rhel7/rhel-7-for-power-rpms

Its OK.For clients

vi /etc/yum.repos.d/ana.repo

[Ana-rhel-7-Power-repo]
name=Ana Red Hat Enterprise Linux $releasever – $basearch
baseurl=http://ipaddr/rhel7/rhel-7-for-power-rpms/
enabled=1
gpgcheck=0

Create Script and Cron Job to Update Your Repositories

On server,

vi /usr/local/bin/updaterepo.sh

echo Update script started at $(date) >> /var/log/updaterepo.log

reposync –gpgcheck -l –repoid=rhel-7-for-power-rpms –download_path=/var/www/html/rhel7 –downloadcomps –download-metadata

echo Update script ended at $(date) >> /var/log/updaterepo.log

Afterthat,

chmod 600 /usr/local/bin/updaterepo.sh

Create a file in /etc/cron.d and name it updaterepo with the following content.

vi /etc/cron.d/updaterepo

@weekly root /usr/local/bin/updaterepo.sh

 

 

Emre Özkan About Emre Özkan

I live in Istanbul/TURKEY and working with Anadolubank.,I am Unix & Backup & Storage Admin in this company. My responsibilities are IBM Power Hardware(E850,P780,P770, etc.),IBM AIX,Tivoli Storage Manager,IBM Tape Libraries,Hitachi VSP and IBM DS8100 Storage.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>