Create yum repository in Redhat Linux

Yum is the package manager that is used in Redhat , Yum searches numerous repositories for packages and their dependencies so they may be installed together in an effort to alleviate dependency issues. Red Hat Enterprise Linux 5 and Red Hat Enterprise Linux 6 uses Yum to fetch packages and install RPMs. We can use our installation media for creating yum repository. Below steps will explain to set up yum repository for locally-mounted DVD on Red Hat Enterprise Linux 6.

 

  1. Create a folder and mount RHEL 6 iso image to that folder.
# mount -o loop /vmstorage/rhel6.iso /repo/

Note: If we are directly using DVD Media, we can mount it without loop option.

# mount /dev/cdrom /repo/
  1. Copy the repo file from the root of the mounted ISO to /etc/yum.repos.d/ and set the appropriate permission.
# cp /repo/media.repo /etc/yum.repos.d/rheldvd.repo

# chmod 644 /etc/yum.repos.d/rheldvd.repo
  1. Edit the new repo file.   Change the gpgcheck=0 setting to 1 and add the following 3 lines (make sure to replace “Server” with “Client” or “Workstation”, depending on the type of RHEL DVD version in use):

enabled=1

baseurl=file:///repo/Server

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

After completing editiong , the   new repo file could look like the following (the mediaid will be different depending on the version of RHEL):

[InstallMedia]

name=Red Hat Enterprise Linux 6.0

mediaid=1285193176.460470

metadata_expire=-1

gpgcheck=1

cost=500

enabled=1

baseurl=file:///repo/Server

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

We can run the the command ‘yum clean all’ once to clean up repository erros. . Also note that if the system is registered to Red Hat Network, yum can be run with the –noplugins option to prevent it from connecting to RHN.

# yum clean all

Loaded plugins: refresh-packagekit, rhnplugin

Cleaning up Everything

# yum clean all --noplugins

Cleaning up Everything

Note:

We can also configure repositories for addition addons like High Availability, LoadBalancer, ResilientStorage, and ScalableFileSystem. By editing the file as below.

# vi /etc/yum.repos.d/rheldvd.repo
[InstallMedia]

name=Red Hat Enterprise Linux 6.0

mediaid=1285193176.460470

metadata_expire=-1

gpgcheck=0

cost=500

enabled=1

baseurl=file:///repo/Server

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[LoadBalancer]

name=Red Hat Enterprise Linux 6.0 - LoadBalancer

mediaid=1285193176.460470

metadata_expire=-1

gpgcheck=0

cost=500

enabled=1

baseurl=file:///repo/LoadBalancer

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[ResilientStorage]

name=Red Hat Enterprise Linux 6.0 - ResilientStorage

mediaid=1285193176.460470

metadata_expire=-1

gpgcheck=0

cost=500

enabled=1

baseurl=file:///repo/ResilientStorage

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[HighAvailability]

name=Red Hat Enterprise Linux 6.0 - HighAvailability

mediaid=1285193176.460470

metadata_expire=-1

gpgcheck=0

cost=500

enabled=1

baseurl=file:///repo/HighAvailability

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[ScalableFileSystem]

name=Red Hat Enterprise Linux 6.0 - ScalableFileSystem

mediaid=1285193176.460470

metadata_expire=-1

gpgcheck=0

cost=500

enabled=1

baseurl=file:///repo/ScalableFileSystem

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

 

  1. We can list the configured repositories using below command.
# yum repolist

Loaded plugins: refresh-packagekit, rhnplugin

This system is not registered with RHN.

RHN support will be disabled.

repo id                                 repo name

HighAvailability                       Red Hat Enterpr

InstallMedia                            Red Hat Enterpr

LoadBalancer                           Red Hat Enterpr

ResilientStorage                       Red Hat Enterpr

ScalableFileSystem                     Red Hat Enterpr

repolist: 3,448

Note:

Below are some basing yum commands.

1) Install a package:

# yum install httpd

2) Remove a package:

# yum remove httpd

3) Update a package:

# yum update httpd

4) Search for a package:

# yum search httpd

Loaded plugins: refresh-packagekit, rhnplugin

This system is not registered with RHN.

RHN support will be disabled.

================================ Matched: httpd ================================

httpd-devel.i686 : Development interfaces for the Apache HTTP server

httpd-devel.x86_64 : Development interfaces for the Apache HTTP server

httpd-manual.noarch : Documentation for the Apache HTTP server

httpd-tools.x86_64 : Tools for use with the Apache HTTP Server

httpd.x86_64 : Apache HTTP Server

mod_dav_svn.x86_64 : Apache httpd module for Subversion server

mod_dnssd.x86_64 : An Apache HTTPD module which adds Zeroconf support

mod_ssl.x86_64 : SSL/TLS module for the Apache HTTP Server

5) Find information about a package:

# yum info httpd

Loaded plugins: refresh-packagekit, rhnplugin

This system is not registered with RHN.

RHN support will be disabled.

Available Packages

Name       : httpd

Arch       : x86_64

Version   : 2.2.15

Release   : 5.el6

Size       : 811 k

Repo       : InstallMedia

Summary   : Apache HTTP Server

URL       : http://httpd.apache.org/

License   : ASL 2.0

Description: The Apache HTTP Server is a powerful, efficient, and extensible

 

: web server.

6) List packages containing a certain term:

# yum list httpd

Loaded plugins: refresh-packagekit, rhnplugin

This system is not registered with RHN.

RHN support will be disabled.

Available Packages

httpd.x86_64                       2.2.15-5.el6                       InstallMedia

7) Find what package provides a particular file:

# yum whatprovides 'path/filename'

Example:

# yum whatprovides /etc/httpd/conf/httpd.conf

Loaded plugins: refresh-packagekit, rhnplugin

This system is not registered with RHN.

RHN support will be disabled.

httpd-2.2.15-5.el6.x86_64 : Apache HTTP Server

Repo       : InstallMedia
Matched from:

Filename   : /etc/httpd/conf/httpd.conf

httpd-2.2.15-5.el6.x86_64 : Apache HTTP Server

Repo       : installed

Matched from:

Other       : Provides-match: /etc/httpd/conf/httpd.conf

8) Update all installed packages with kernel package :

# yum -y update

9) To update a specific package:

# yum -y update openssh-server