Friday, November 28, 2014

Creating Local Yum Repository Using an ISO or DVD for RHEL5, 6 and 7

Creating a local yum repository allows a convenient way of installing the required rpms as part of an Oracle installation. Using yum repository is convenient as oppose to installing required rpms via rpm -i as yum fetches the necessary dependencies from the repository. The post gives the steps for setting up local yum repository for RHEL5, RHEL6 and RHEL7 using either ISO or DVD which has the installation.
Mount the ISO or the DVD. In all cases the ISO or DVD is mounted on /media mount point.

Setting up local yum repository on RHEL 5.
Currently there are no repositories.
 yum repolist
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
repolist: 0
Create the repository file (extension must be .repo).
cat rhel5.repo
[RHEL5ISO]
name=RHEL 5 ISO
baseurl=file:///media/Server
enabled=1
gpgcheck=1
gpgkey=file:///media/RPM-GPG-KEY-redhat-release
The repository data is taken from "repodata/repomd.xml". In RHEL5 this is located inside the Server directory for linux server installation. Similar repomd.xml exists for cluster,clusterstorage and VT. Setting only /media for baseurl will result in following error
file:///media/repodata/repomd.xml: [Errno 5] OSError: [Errno 2] No such file or directory: '/media/repodata/repomd.xml'
If the gpgcheck is set to 1 (enabled) then prior to installing a package authenticity of it is checked using the GPG signatures. For this to work the gpgkey must be set to the RPM-GPG-KEY-redhat-release file which is available under /media.
Once the file is setup run the following commands to clean and list the repository data.
yum clean all
Loaded plugins: rhnplugin, security
Cleaning up Everything

yum repolist
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
RHEL5ISO                                                                                                                                                                                                               | 1.5 kB     00:00
RHEL5ISO/primary                                                                                                                                                                                                       | 920 kB     00:00
RHEL5ISO                                                                                                                                                                                                                            3285/3285
repo id                                   repo name                                      status
RHEL5ISO                                  RHEL 5 ISO                                     enabled: 3,285 repolist: 3,285
Run yum list or yum grouplist to test the repository is working.
yum grouplist
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Group Process
RHEL5ISO                                                                                                                                                                                                               | 1.5 kB     00:00
RHEL5ISO/primary                                                                                                                                                                                                       | 920 kB     00:00
RHEL5ISO/group                                                                                                                                                                                                         | 1.0 MB     00:00
Installed Groups:
   Administration Tools
   Authoring and Publishing
   Development Libraries
   Development Tools
   Editors
   FTP Server
   GNOME Desktop Environment
   GNOME Software Development
   Graphical Internet
   Legacy Network Server
   Legacy Software Development
   Legacy Software Support
   Mail Server
   Network Servers
   Office/Productivity
   Printing Support
   Server Configuration Tools
   System Tools
   Text-based Internet
   X Software Development
   X Window System
Available Groups:
   DNS Name Server
   Engineering and Scientific
   Games and Entertainment
   Graphics
   Java Development
   KDE (K Desktop Environment)
   KDE Software Development
   MySQL Database
   News Server
   OpenFabrics Enterprise Distribution
   PostgreSQL Database
   Sound and Video
   Web Server
   Windows File Server
Done



Setting up local yum repository on RHEL 6 and RHEL 7.
Setting up local yum repository for both RHEL6 and RHEL7 is similar and same repo file could be used for both RHEL versions. Only difference between these RHEL versions and the RHEL5 is the baseurl.
cat rhel6.repo
[RHEL6ISO]
name=RHEL 6 ISO
baseurl=file:///media
enabled=1
gpgcheck=1
gpgkey=file:///media/RPM-GPG-KEY-redhat-release
The "repodata/repomd.xml" is available from the base media directory. As such baseurl is set to the mount point of the ISO or the DVD.
Run yum clean all and yum repolist as before and use grouplist to validate the repository.
From RHEL 6
 yum grouplist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Group Process
RHEL6ISO/group_gz                                                                                                                                                                                                      | 204 kB     00:00 ...
Installed Groups:
   Additional Development
   Base
   Compatibility libraries
   Console internet tools
   Debugging Tools
   Desktop Platform
   Dial-up Networking Support
   Directory Client
   E-mail server
   FTP server
   Fonts
   General Purpose Desktop
   Graphical Administration Tools
   Hardware monitoring utilities
   Java Platform
   KDE Desktop
....
From RHEL7
 yum grouplist
Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Available environment groups:
   Minimal Install
   Infrastructure Server
   File and Print Server
   Basic Web Server
   Virtualization Host
   Server with GUI
Available Groups:
   Compatibility Libraries
   Console Internet Tools
   Development Tools
   Graphical Administration Tools
   Legacy UNIX Compatibility
   Scientific Support
   Security Tools
   Smart Card Support
   System Administration Tools
   System Management
Done