You are on page 1of 6

Linux 101

Laboratory 04. Software Management


RPM and YUM

Exercise 1

This exercise can be experimented with a fresh installation of Red Hat Enterprise Linux. We will use the
rpm packages found on the installation dvd (the Server directory on the dvd) that we mounted at
/mnt/distdvd.

We want to install a mysql database server. Looking through the packages we can see that a mysql-
server package is available. First of all we query the installed packages list to see if mysql is installed.

# rpm -qa mysql

The query does not output anything so there is no mysql related package installed. We change to the
directory containing the rpms (#cd /mnt/distdvd/Server) and then issue the following command to start
the installation:

# rpm -ivh mysql-server-5.0.45-7.el5.i386.rpm

Note: In your setup some other version of the package might be available. The safest way to write this
command line is to write “rpm –ivh mysql-server” and then hit the TAB key to autocomplete
the package file name.

The options given to the rpm command are: -i (or --install) specifies the operation, -v tells rpm to be
verbose and output everything, -h makes rpm display hashes as a completion indication.

After we run the above command we get the following output:

warning: mysql-server-5.0.45-7.el5.i386.rpm: Header V3 DSA signature: NOKEY,


key ID 37017186
error: Failed dependencies:
libmysqlclient.so.15 is needed by mysql-server-5.0.45-7.el5.i386
libmysqlclient_r.so.15 is needed by mysql-server-5.0.45-7.el5.i386
mysql = 5.0.45-7.el5 is needed by mysql-server-5.0.45-7.el5.i386
perl(DBI) is needed by mysql-server-5.0.45-7.el5.i386
perl-DBD-MySQL is needed by mysql-server-5.0.45-7.el5.i386
perl-DBI is needed by mysql-server-5.0.45-7.el5.i386
From this output we can clearly see that we first need to install some other packages that mysql-server
depends on: we need the mysqlclient, the perl-DBI and perl-DBD-MySQL packages.

1
Trying to install the two perl related packages we give the following command:

# rpm -ivh perl-DBI-1.52-2.el5.i386.rpm perl-DBD-MySQL-3.0007-2.el5.i386.rpm

And get the output:

warning: perl-DBI-1.52-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID


37017186
error: Failed dependencies:
libmysqlclient.so.15 is needed by perl-DBD-MySQL-3.0007-2.el5.i386

We see that we still got two dependency problems. To install the perl-DBD-MySQL package we need to
have installed the mysqlclient first. The perl-DBI package can be installed without a problem so we issue
the installation command for this package:

# rpm -ivh perl-DBI-1.52-2.el5.i386.rpm

warning: perl-DBI-1.52-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID


37017186
Preparing... ########################################### [100%]
1:perl-DBI ########################################### [100%]

The package is now installed despite the warning about the missing signature key. We do not care about
this warning yet and we can even make rpm ignore the missing key by providing the --nosignature
option in the command.

We now want to install the mysqlclient because both the mysql-server and the perl-DBD-MySQL
packages depend on it:

# rpm -ivh mysql-5.0.45-7.el5.i386.rpm

warning: mysql-5.0.45-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID


37017186
Preparing... ########################################### [100%]
1:mysql ########################################### [100%]

We can now install the perl-DBD-MySQL:

# rpm -ivh perl-DBD-MySQL-3.0007-2.el5.i386.rpm

warning: perl-DBD-MySQL-3.0007-2.el5.i386.rpm: Header V3 DSA signature:


NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:perl-DBD-MySQL ########################################### [100%]

And finally the mysql-server package:

# rpm -ivh mysql-server-5.0.45-7.el5.i386.rpm

2
warning: mysql-server-5.0.45-7.el5.i386.rpm: Header V3 DSA signature: NOKEY,
key ID 37017186
Preparing... ########################################### [100%]
1:mysql-server ########################################### [100%]

We can see that now, after we manually handled all its dependencies, mysql-server installed without
complaints. We can now query the installed packages list and search for ‘mysql’ inside the list; we
should get two packages:

# rpm -qa | grep mysql

mysql-5.0.45-7.el5
mysql-server-5.0.45-7.el5

Exercise 2

In this exercise we will uninstall all the packages installed in the previous exercise. First of all we have to
remove the mysql-server as it is the top of our dependency chain.

# rpm -e mysql-server

With a simple query we see that only the client is installed now:

# rpm -qa | grep mysql


mysql-5.0.45-7.el5

Now we try to remove the client:

# rpm -e mysql
error: Failed dependencies:
libmysqlclient.so.15 is needed by (installed) perl-DBD-MySQL-3.0007-
2.el5.i386

The error tells us that we cannot uninstall mysql as there is one installed package that uses it. So we first
have to clear any dependencies and then we can perform the uninstall.

Note: At this point we could ignore dependencies but that is not advisable as we would leave some
broken dependency chains on our system. In other words, ignoring dependencies could lead to installed
but not functional software.

# rpm -e perl-DBD-MySQL
# rpm -e mysql
# rpm -e perl-DBI
# rpm -qa | grep mysql
# rpm -qa | grep DBI
# rpm -qa | grep DBD

3
As we can see from the queries there is no sign left of mysql or the two other dependencies.

Exercise 3

We saw that trying to manage package dependencies ourselves can be a really cumbersome activity. We
can avoid this trouble by using a metapackager instead. A metapackager would save us a lot of work as
we don’t need to bother finding and downloading packages and especially we don’t have to worry about
dependencies. Before we can install something using YUM (rpm based metapackager) we will configure
one repository so that yum knows where to look for packages.

YUM’s repositories configuration files are stored in the /etc/yum.repos.d/ directory. Inside that
directory we duplicate the existing configuration file under another name:

#cd /etc/yum.repos.d/
#cp rhel-debuginfo.repo rhel-distdvd.repo

Now we edit the new file (rhel-distdvd.repo) to suit our needs. The final contents of this file will be:

[rhel-distdvd]
name=Red Hat Enterprise Linux Distribution DVD
baseurl=file:///mnt/distdvd/Server
enabled=1

We changed the identifier, the name, the url to point to our distribution dvd and we have enabled
(made YUM use it) the repository by changing the enabled property to 1. Now that we have the
repository configured we will give the command to install mysql-server.

# yum --nogpg install mysql-server

We included the --nogpg option because otherwise the install would fail as we didn’t download and
install a public key for this repository and yum cannot check the authenticity of the packages. Including
the publick key does not meet our point at this moment so we’ll just skip it although in a production
environment it is advisable to verify if packages come from a trusted source.

Doing some queries we can see that from a single command all the needed packages were installed:

# rpm -qa | grep mysql


mysql-5.0.45-7.el5
mysql-server-5.0.45-7.el5
# rpm -qa | grep DBD
perl-DBD-MySQL-3.0007-2.el5
# rpm -qa | grep DBI
perl-DBI-1.52-2.el5

4
Exercise 4

Now we’d like to experiment a little with uninstalling. This will help us remember a few more commands
and obtain a deeper understanding of the behavior of package dependencies. So let’s try and uninstall
mysql-server:

#yum remove mysql-server

The command resolves dependencies and then asks us for a confirmation. The output looks similar to
this:

=============================================================================
Package Arch Version Repository Size
=============================================================================
Removing:
mysql-server i386 5.0.45-7.el5 installed 21 M

Transaction Summary
=============================================================================
Install 0 Package(s)
Update 0 Package(s)
Remove 1 Package(s)

Is this ok [y/N]:

When we installed mysql-server three other packages were brought in by dependencies. Now at
uninstallation no other packages are removed. We’ll respond with ‘N’ so we can make further tests. Try
now to remove the perl-DBD-MySQL package:

# yum erase perl-DBD-MySQL

We can see that both perl-DBD-MySQL and mysql-server are proposed for removing. If we now give the
command to remove perl-DBI we can see that all four packages are getting uninstalled. We can now
draw the dependency tree of those packages:

mysql-server

mysql perl-DBD-MySQL

perl-DBI

5
Now we can explain what was happening when we gave the remove commands. The perl-DBI is a leaf in
our tree; it works without the other packages. The mysql instead, does not function without perl-DBI. So
uninstalling perl-DBI would render mysql useless and as such, mysql is also uninstalled. But we have to
follow the dependencies along and we see that without mysql the mysql-server package would not
function. Thus mysql-server is also uninstalled. And so on and so forth.

You might also like