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
Code alignment center – is something horrible