Installing/uninstalling/updating software on linux distributions (in our case RHEL5/Fedora Core 8) has not been very easy. There was always a chance of dependency problem. There are 2 methods of installing packages on Red Hat systems, through using binary .rpm format or source format (tar.gz,tar.bz2) format.
For effortless installation YUM(Yellow Dog Updater,Modified) was developed. Yum is extremely powerful. Here we will be learning how to make your linux system as a YUM Server & also how to use yum on client side.
Making RHEL5 as Yum Server. RHEL5 comes in 5 Cd's. Here we are giving step by step procedure of configuring the Yum Server.
First put the 1st cd into cdrom/dvd drive of your system.
[root@server1 ~]# mkdir /dvd
[root@server1 ~]# mount /dev/cdrom /dvd
[root@server1 ~]# cp -a /dvd/. /var/ftp/pub/
[root@server1 ~]# umount /dvd
Repeat the above process for all the five cds. If it is giving any overwriting messages press 'y' there to confirm overwriting.
To create FTP Server based yum server do the following 2 steps[root@server1 ~]# service vsftpd start
[root@server1 ~]# chkconfig vsftpd on
[root@server1 ~]# cd /var/ftp/pub/
[root@server1 pub]# rpm –import RPM-GPG-KEY-*
or
rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-*
[root@server1 pub]# cd Server
[root@server1 Server]# rpm -ivh createrepo-0.4.4-2.fc6.rpm
your version of createrepo can be little bit different so always make a habit of using Tab Completion after typing few characters.
[root@server1 Server]# cd ..
[root@server1 pub]# createrepo .
createrepo creates your collection of files into repository data.
Now above steps have created the yum server. You can now configured the client system to use the yum server. You can use the server itself as a client to test all the yum commands. In present case we are just doing that.
[root@server1 pub]# mkdir /yum
[root@server1 pub]# mv /etc/yum.repos.d/. /yum/
this will move all the files in /etc/yum.repos.d/ to /yum directory. We do not need these files. If any need arises in future then these files can be moved back into original position. open the file yum.conf on yum server or client systems and add these lines at bottom[root@server1 pub]# vi /etc/yum.conf
[abcd]
name=yum-server
baseurl=ftp://192.168.0.201/pub
enabled=1
gpgcheck=1
save the file & your yum server is ready
[root@server1 pub]# cd
[root@server1 ~]# yum install zip
will install the zip package & dependencies. It will ask for confirmation press 'y' there
[root@server1 ~]# yum remove zip
will remove the zip package
[root@server1 ~]# yum update zip
will update the package if new version is available
[root@server1 ~]# yum list telnet
will list the specific telnet package
[root@server1 ~]# yum search telnet
it will find all the packages that have anything related to telnet
[root@server1 ~]# yum provides /etc/inittab
it will list the packages that contains /etc/inittab file
[root@server1 ~]# yum list tel\*
it will list all the packages that begin with tel word
[root@server1 ~]# yum list available
this will list all the packages available in repositories that can be installed
[root@server1 ~]# yum list installed
this will list all installed packages
[root@server1 ~] yum check-update
this will let you know if there are any updates available
[root@server1 ~] yum update
this will update all the currently installed packages
[root@server1 ~]# yum info telnet
it gives the detailed information about telnet package
There are graphic tools available for package management & updations. The tools are pirut & pup. Go to graphic mode, open the terminal window & type pirut or pup. These graphic tools are very easy to use & learn
[root@server1 ~]# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum
keepcache=1
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
metadata_expire=1800
[local]
name=local
#baseurl=file:///var/ftp/pub
baseurl=ftp://192.168.0.201/pub
enabled=1
gpgcheck=1
The meanings of different [main] options are :cachedir : the directory where yum stores cache data. Default is /var/cache/yum
keepcache : 1 means keep cache
0 means do not keep cache
debuglevel : increase/decrease the no. of things printed in log file (/var/log/yum.log)
range 0-10 (0-min,10-max)
logfile : absolute yum log file (tail -f /var/log/yum.log)
distroverpkg : the package used by yum to determine distribution version. Default is redhat-release
tolerant : 1 means tolerant of command line errors. Suppose you are giving command yum install telnet zip if one of these is already installed then it will not give error.
0 does not tolerate errors
exactarch : 1 means use the exact architect i.e do not update an i386 package by using i686 package
0 do not bother
obsoletes : it enables obsolete processing logic. Useful when the distribution version changes.
gpgcheck : 1 means perform gpg signature check
0 means do not perform gpg signature check
plugins : yum's power can be extended through use of plugins
1 means enable plugins
0 means disable plugins
metadata_expire: time in seconds after which metadata will get expired
assumeyes : 0 mean yum will prompt you for confirmation
1 mean it will not prompt for confirmation (e.g yum -y install telnet)
assumeyes=1 behaves like -y option at the command line
Repositories Details :[local] it is the repository ID unique and single word
name=local this is the name of the repository
baseurl :
baseurl=ftp://192.168.0.201/pub
or
baseurl=file:///var/ftp/pub
or
baseurl=http://192.168.0.201/pub
If repository is local the use the 'file' & if the repository on remote system then use http/ftp method
enabled 1 mean use the repository
0 mean do not use the repository
How to use additional repository (in this case web server based) : [root@server1 ~]# cat >/etc/yum.repos.d/web.repo
[web]
name=web based yum repository
baseurl=http://192.168.0.201/pub
enabled=1
gpgcheck=1
save the file & after that open the file /etc/yum.conf
[root@server1 ~]# vi /etc/yum.conf
and in the [local] repository section change 'enabled=1' to 'enabled=0'
[root@server1 ~]# yum install telnet
now the yum on client side will be using 'web' repository instead of 'local' repository.
What is a package: is basically a collection of compressed files & dependency information. The RPM(Red Hat Package Manager) greatly simplifies the installation/removal/updation of packages. Let us consider one package “telnet-0.17-38.el5.i386.rpm”
the package uses the following format
packagename-version-release.architecture.rpmwhere 'version' points to open source version, 'release' points Red Hat specific patch, 'architecture' points to hardware architecture of system. It could be i386,ppc,noarch.
What is a repository: is a directory containing packages & support files. Yum uses this directory locally/remotely for package management (i.e for installing/removing/upgrading & automatically resolving the dependencies)
when we run createrepo command it creates many support files
primary.xml.gz : contains the list of all rpms & their dependencies
filelists.xml.gz : contains the list of all the files in all the packages
other.xml.gz : contains additional information like changelog
repomd.xml : contains checksum, timestamps value of above three files. After client has used the yum server, the client caches all files for future reference. So if the repository is changed then the timestamp and checksum will get changed. So repomd.xml will indicate changes in repository & so the client will refresh the cache.
comps.xml : this optional file contains information about groups.
All these files all located in subdirectory 'repodata'