1. Home
  2. General
  3. How do I create a RHEL or Bright repository for my organization?

How do I create a RHEL or Bright repository for my organization?

In certain cases, the Bright cluster is not able to access the internet directly or having a local repository withing the companies intranet is beneficial e.g. in the case were a site is hosting multiple clusters. This KB article will describe how to create a local repository using the Bright headnode’s webserver. The same instructions can be used also in the case that the local repository needs to be created on a non-Bright headnode provided that it has YUM installed and that the remote repositories are configured properly or the RPMs can be obtained from a DVD or ISO image.

cd /var/www/html
mkdir repos
cd repos

There are several ways to add RPMs. You can either copy them directly from a Bright ISO or DVD:

mount -o loop <ISO image> /mnt/iso
cp -r /mnt/iso/path/to/rpm/rectory /var/www/html/repos

or use reposync, a utility that will create a local copy of an online YUm repository. 

To install reposync:
# yum install yum-utils

Provided that the YUM repositories are properly configured on the headnode (see the output of the ‘yum repolist’ command), the following script can be used:
#!/bin/bash
## declare an array variable
declare -a arr=("rhel-6-server-rpms" "rhel-6-server-optional-rpms" "rhel-server-dts2-6-rpms", "cm-rhel6-7.0", "cm-rhel6-7.0-updates")
## now loop through the above array
for i in "${arr[@]}"
do
   cd /var/www/html/repos mkdir -p $i
   reposync --gpgcheck -l --repoid=$i  -n
   cd /home/rhel/$i
   createrepo -v /var/www/html/repos/$i
done

The -n flag at the end of the reposync command instructs reposync to download only the latest version of each RPM that is available on the remote repository. You can add ore remove repositories from the array variable as needed.

To use the newly created local YUM repository create a .repo configuration file in /etc/yum.repos.d for the headnodes and /cm/shared/<software image>/etc/yum.repos.d for the software images.

[root@kerndev ~]# cat local-yum-repo.repo
[rhel-6-server-rpms]
name=My Red Hat Enterprise Linux $releasever - $basearch
baseurl=http://<hostname of webserver>/repos/rhel-6-server-rpms
enabled=1
gpgcheck=0
[rhel-6-server-optional-rpms]
name=My Red Hat Enterprise Linux $releasever - $basearch
baseurl=http://<hostname of webserver>/rhel-6-server-optional-rpms enabled=1
gpgcheck=0

etc.

If the repositories need to reside outside outside /var/www/html becuase e.g. the /var partition is too small then create an allias directory in the webserver’s configuration:
vim /etc/httpd/conf.d/local-repo.conf

Alias /repos /home/repos

<Directory /home/repos>
 Options Indexes MultiViews FollowSymLinks
 Order allow,deny
 Allow from all
</Directory>   and restart the webserver:   # service httpd restart

Updated on August 18, 2020

Was this article helpful?

Related Articles

Leave a Comment