Sie sind auf Seite 1von 5

Configuring Yum in RHEL5

In this article I am going to discuss how we can configure Yum for DVD sources in
RHEL5.
Yum is the package management tool used these days. It has replaced the old
"up2date" command which use to come with RHEL4. This command used to get updates
from the RHN (Redhat Network) for the installed operating system, if the user using
that command had bought a support/update entitlement from Redhat. But with the new
version of Redhat and then it's free clone Centos5 "up2date" has been dropped out
and instead of it "yum" as been included. "yum" was there in Fedora core for a long
time and was use to update packages via 3rd party repositories. It started becoming
mature with Fedora and now finally when Redhat thought it to be matured enough to
make it's way into RHEL it's here.

The major problem one face with Yum is to configure it for DVD/CD sources. Yum by
default doesn't comes enabled for these sources and we need to explicitly enable
it. I don't know what is the reason behind not enabling Yum for these sources by
default but, whatever it is we can still hack "yum" on our own and can configure it
to use DVD/CD install sources.

Before starting I would like to mention that I am using a DVD source in this
article which is represented by "/dev/dvd" and mounted on "/media/cdrom". The steps
I tell here can be easily extended for CD sources as well. Later in this article I
will tell how we can configure a local yum repository and use it for package
management in our LAN clients.

First of all you have to put in the media CD/DVD into your CD/DVD ROM/Writer. Then
you need to mount it manually if you are login via root user in a GUI. To do so

mount /dev/dvd /media/cdrom

After mounting the DVD we need to copy the content of the DVD onto a directory. For
example I have a directory /dvd/rhel5/. I will copy the whole contents of
/media/cdrom into /rhel5. This is the command

cp -r /media/cdrom/* /home/repos

After copying the contents it's time to do some modifications. First of all we need
to bring the xml files defining the groups to directory one level higher.

mv /home/repos/Server/repodata/comps-rhel5-server-core.xml /home/repos/Server
mv /home/repos/VT/repodata/comps-rhel5-vt.xml /home/repos/VT
mv /home/repos/Cluster/repodata/comps-rhel5-cluster.xml /home/repos/Cluster
mv /home/repos/ClusterStorage/repodata/comps-rhel5-cluster.xml
/home/repos/ClusterStorage

Now we need to delete the repodata/ directories which comes with the default
install tree. The reason behind this is that in their xml files we have a string
xml:base="media://1170972069.396645#1" .....
This string is present in repmod.xml as well as primary.xml.gz. This thing creates
problem with using DVD/CD sources with yum. So we need to do the following

rm -rf /home/repos/Server/repodata
rm -rf /home/repos/VT/repodata
rm -rf /home/repos/Cluster/repodata
rm -rf /home/repos/ClusterStorage/repodata

After we have deleted the default repodata/ directories it's time to re-create them
using the "createrepo" command. Now this command doesn't comes by default I guess
so we need to install it's rpm
rpm -ivh /home/repos/Server/createrepo-0.4.4-2.fc6.noarch.rpm

Next step is to run this command. Before running this command we need to switch to
the /dvd/ directory. Then run the commands listed below

createrepo -g comps-rhel5-server-core.xml /home/repos/Server/


createrepo -g comps-rhel5-vt.xml /home/repos/VT/
createrepo -g comps-rhel5-cluster.xml /home/repos/Cluster/
createrepo -g comps-rhel5-cluster-st.xml /home/repos/ClusterStorage/

The above commands will do most part of the job. Now it's time to configure the
/etc/yum.conf for our local repository. Note that we can also create separate repo
files in /etc/yum.repos.d/ directory but I have tried it without any luck. So do
the following

vi /etc/yum.conf

In this file type in the following: # PUT YOUR REPOS HERE OR IN separate files
named file.repo

# in /etc/yum.repos.d
[Server]
name=Server
baseurl=file:///home/repos/Server/
enabled=1
gpgcheck=1
gpgkey=file:///home/repos/RPM-GPG-KEY-redhat-beta
[VT]
name=Virtualization
baseurl=file:///dvd/rhel5/VT/
enabled=1
gpgcheck=1
gpgkey=file:///home/repos/RPM-GPG-KEY-redhat-beta
[Cluster]
name=Cluster
baseurl=file:///dvd/rhel5/Cluster/
enabled=1
gpgcheck=1
gpgkey=file:///home/repos/RPM-GPG-KEY-redhat-beta
[ClusterStorage]
name=Cluster Storage
baseurl=file:///dvd/rhel5/ClusterStorage/
enabled=1
gpgcheck=1
gpgkey=file:///home/repos/RPM-GPG-KEY-redhat-beta

We can also use GPG key signing. For that write on top of the above lines

gpgenabled=1
gpgkey=file:///dvd/rhel5/RPM-GPG-KEY-fedora file:///dvd/rhel5/RPM-GPG-KEY-fedora-
test file:///dvd/rhel5/RPM-GPG-KEY-redhat-auxiliary file:///dvd/rhel5/RPM-GPG-KEY-
redhat-beta file:///dvd/rhel5/RPM-GPG-KEY-redhat-former file:///dvd/rhel5/RPM-GPG-
KEY-redhat-release

This will be sufficient for now. Let's create the yum cache now.

yum clean all


yum update
The below commands are required if gpgcheck=1 and we are getting error after
performing
yum install <package name>
as : warning:rpmts_HdrFromFdno:V3 DSA signature:NOKEY
Error:Could not find GPG key

rpm -import /home/repos/RPM-GPG-KEY-redhat-beta


rpm -import /home/repos/RPM-GPG-KEY-redhat-release

yum install -y <package name>


yum list <package name>

It's all done now. We can now use "yum" command to install/remove/query packages
and now yum will be using the local yum repository. Well I am mentioning some of
the basic "yum" commands which will do the job for you for more options to the
"yum" command see the man page of "yum".
yum install package_name Description: Installs the given package
yum list Description: List's all available package in the yum database
yum search package_name Description: Search for a particular package in the
database and if found print's a brief info about it.
yum remove package_name Description: Remove's a package.

Now I will mention the steps you can use to extend this local repository to become
a local http based repository so that LAN clients can use it for package
management. I will be using Apache to configure this repository as it's the best
available software for this job. Do configure the repository for http access via
LAN clients we need to make it available to them. For that I am declaring a
virtualhost entry in apache's configuration file. This is how it looks for me

ServerAdmin webmaster@server.example.com
ServerName server.example.com
DocumentRoot "/dvd/rhel5/"
ErrorLog logs/server.example.com-error_log
CustomLog logs/server.example.com-access_log common

After this service httpd start


chkconfig httpd on

Now it's time to make a yum.conf file that we will use at the client end. I am
writing my yum.conf for clients. You can use it and modify according to your setup.

[main]
cachedir=/var/cache/yum
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
obsoletes=1
plugins=1
metadata_expire=1800
gpgcheck=1

# PUT YOUR REPOS HERE OR IN separate files named file.repo


# in /etc/yum.repos.d
[Server]
name=Server
baseurl=http://192.168.1.5/Server/
enabled=1
[VT]
name=Virtualization
baseurl=http://192.168.1.5/VT/
enabled=1
[Cluster]
name=Cluster
baseurl=http://192.168.1.5/Cluster/
enabled=1
[ClusterStorage]
name=Cluster Storage
baseurl=http://192.168.1.5/ClusterStorage/
enabled=1

Copy this file to /etc/ directory of the client end and replace it with the
original file there. After copying is done it's time to do this

yum clean all


yum update
rpm --import /etc/pki/rpm-gpg/*

Now you can use yum on the client end to just install any package and it will
communicate with the local repo server to get the package for you. You can also use
pirut in the same way to get things done.

So this is how we can configure Yum for RHEL5 Server and can also use it to create
our own local repo server for the LAN. Hope you have enjoyed reading and had your
hands done on this :).
Posted by Praveen at 10:17 PM
8 comments:

Peter said...

The 4th 'mv' command has a slight mistake, should be:

mv /dvd/rhel5/ClusterStorage/repodata/comps-rhel5-cluster-st.xml
/dvd/rhel5/ClusterStorage

Thanks for putting this guide together!


June 19, 2009 5:59 AM
Suhas Prabhu said...

Excellent. Great article. Thank You very much.


August 17, 2009 10:21 PM
rocky said...

thanks for that


but we found problem when i am installing rpm through yum install
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 37017186
August 19, 2009 11:55 AM
danny said...

Amazing article, i was having a terrible time resolving the dependency issues
whie trying to build.....But i too get the warning: rpmts_HdrFromFdno: Header V3
DSA signature: NOKEY, key ID 37017186 error and as a result cannot install the
pkgs...Any Help??
February 17, 2010 6:22 AM
danny said...

yum install --nogpgcheck

Ok googled for the solution and it works fine:)


February 17, 2010 6:26 AM
Pushpendra said...

Excellent friend...
I am very lucky to get it. Now I will be the most freqently visiting person to
these links. Thanks... It worked for me...
August 2, 2010 10:50 AM
BG said...

This is an excellent article and I really appreciate the details that are
provided. I always had problems resolving dependencies and reading from DVDs
without RHN registration, but this helped me a lot.
September 14, 2010 4:26 PM
manjunath said...

it should be createrepo -g comps-rhel5-server-core.xml /dvd/rhel5Server/


...great article thanks for posing

Das könnte Ihnen auch gefallen