Saturday, April 19, 2014

Configuring local Yum repository on RHEL 6

It has been quite sometime since I played around with Redhat Linux. Because Oracle has the same replica and I love Oracle for so many reasons, I stick to Oracle Linux especially at my home setup. But yesterday was a different day.

An early frustration sat in when I was unable to access internet inside the VM. The problem was circular. Internet required installation of guest additions, guest additions required access to some yum repository and my choice of yum repository i.e. Oracle's public yum required Internet. A friend told me that I should configure local yum repository using the installation media.

So, I did and here are the steps if you want to do the same as well.

Please note that the steps are basic and all I am doing is to configure Packages directory of my ISO image as yum repository. You can create multiple yum repositories and define different categories and all that complicated stuff.

First create a folder.

# mkdir -p /yum

Navigate to your mounted ISO image and copy the contents of Packages folder.

#  cd /media/RHEL_6.2\ x86_64\ Disc\ 1/Packages
# cp -rf . /yum/

The creation of yum repository requires that you have "createrepo" and "ftp" packages installed. So while you are in Packages folder, install these two packages manually using rpm. Use the following code.

# rpm -ivh deltarpm-**.el6.x86_64.rpm python-deltarpm-**.el6.x86_64.rpm createrepo-**.rpm
# rpm -ivh vsftpd-**.x86_64.rpm

Navigate to /yum folder where you copied all packages and use the following command to create yum repository.

# createrepo .
2030/3596 - libcanberra-devel-0.22-1.el6.i686.rpm
iso-8859-1 encoding on Ville Skytt▒ - 2.8.2-2

3596/3596 - python-enchant-1.3.1-5.2.el6.x86_64.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata

Add this repository to yum repository list. You will have to add the following lines in /etc/yum.repos.d/rhel-source.repo file.

[rhel6-disk]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Source
baseurl=file:///media/rhel6_dvd/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/$

And that's it. You can use yum now to install packages from your local installation media. You can verify by querying the repository list.

# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
rhel6-disk                                                                                                                                       | 1.3 kB     00:00 ...
rhel6-disk/primary                                                                                                                               | 1.6 MB     00:00 ...
rhel6-disk                                                                                                                                                    3596/3596
repo id                                                   repo name                                                                                               status
rhel6-disk                                                Red Hat Enterprise Linux 6Server Beta - x86_64 - Source                                                 3,596
repolist: 3,596

No comments:

Post a Comment