Pages

Monday 22 October 2012

Package Management using "rpm" command and YUM Server


One of the major duties of a system administrator is software management. New applications are installed. Services are updated. Kernels are patched. Without the right tools, it can be difficult to figure out what software is on a system, what is the latest update, and what applications depend on other software.

                      Installing packages using rpm command.
Syntax of "rpm" command is: 

#rpm [options] packagefilename

Options      Description
-i          =     To Install a Package
-v         =     To Verbose Mode 
-h         =     To Print # (hash) sign
-U        =     To Upgrade/Install a Package 
-F           =       To Upgrade a Package if previous version is already installed
-e         =     To Remove a Package 
-q         =     To Query a package 

To Install a package:
#rpm -ivh /path/of/package_file_name
Example: #rpm -ivh vsftpd-2.2.2-11.el6_3.1.x86_64.rpm

To Query about the package:
#rpm -q package_Name
Example: #rpm -q vsftpd

To Remove a package:
#rpm -e package_Name
Example: #rpm -e vsftpd

To Update a package:
#rpm -Uvh /path/of/package_file_name
Example: #rpm -Uvh vsftpd-2.2.2-11.el6_3.1.x86_64.rpm

                      More "rpm" Query Commands with Examples

rpm -qa                                   Lists all installed packages.

#rpm -qa 

rpm -qf /path/to/file                Identifies the package name which created this file.

#rpm -qf /etc/vsftpd/vsftpd.conf

rpm -qc packagename            Lists all configuration files which created by this package.

#rpm -qc vsftpd

rpm -qi packagename             Displays basic information about the package.

#rpm -qi vsftpd 

rpm -ql packagename             Lists all files which is created by this package.

#rpm -ql vsftpd

rpm -qd packagename             Lists all Document files which is created by this package.

#rpm -qd vsftpd

rpm -qR packagename           Display all dependencies; you can’t install this package without them.

#rpm -qr vsftpd

NOTE: When a package is erased with the -e switch. If a configuration file has been changed, it’s also saved with a .rpmsave extension in the same directory.


List shell scripts that may run after the package is install or uninstall
#rpm -q packagename --scripts

Example-: #rpm -q httpd --scripts 


                             Installing Package using YUM
Yellowdog Update, Modified (YUM) is a program that manages installation, updates and removal for Red Hat package manager (RPM) systems. YUM allows the user to update groups of machines without having to update each RPM separately.

Other features of the YUM package manager include:
  • Simple interface.
  • Multiple repositories.
  • Simple config file.
  • Fast operation.
YUM was created by Seth Vidal and volunteer developers. The program is written in Python and was released under the GNU General Public License GPL.

                            Configure YUM server on RHEL 6/CentOS 6

Step1. Insert the RHEL 6 DVD in to DVD ROM and mount it.

#mount /dev/sr0 /mnt/

#cd /mnt/Packages/

#rpm -ivh vsftpd-2.2.2-11.el6_3.1.x86_64.rpm 

#rpm -ivh deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm

#rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm

#rpm -ivh createrepo-0.9.9-17.el6.noarch.rpm

Now copy entire RHEL6 DVD into /var/ftp/pub/rhel6/dvd

NOTE-: first ensure that you have enough space approx 4 GB in /var/ftp/pub/rhel6/dvd

#mkdir -p /var/ftp/pub/rhel6/dvd 

#cp -rvf /mnt/* /var/ftp/pub/rhel6/dvd

#cd /etc/yum.repos.d/

#ls -l 

NOTE-: in this location, may be one or two sample file is available, So you can delete them and create your own repository file with extension .repo.

#cd /etc/yum.repos.d/

#rm -rf *
#vim yum.repo
[yum_server]
name=Red Hat Enterprise Linux
baseurl=file:///var/ftp/pub/rhel6/dvd  #this is the baseurl syntax to use the local path of packages, if you want to access remote repository, Please see client side yum configuration file for syntax. 
enabled=1
gpgcheck=0

:wq  (save and exit) 

#createrepo -v /var/ftp/pub/rhel6/dvd


#service vsftpd restart
#chkconfig vsftpd on

Please note that, if you want to provide access of this repository using HTTP protocol to clients , you have to do the following configuration.
    #yum install httpd
    #service httpd restart 
    #chkconfig httpd on 
    #ln -s /var/ftp/pub/ /var/www/html/

    Yum Server Configuration is finished, So It's a time to Configure YUM Client to access this repository using FTP or HTTP Protocol. 
                                              YUM Client Configuration 
    #cd /etc/yum.repos.d/
    #rm -rf *
    #vim yum.repo
    [yum_client]
    name=Red Hat Enterprise Linux 


    baseurl=http://<IP_ADDRESS>/pub  #IP_ADDRESS of HTTPD server
                                     or 
    baseurl=ftp://<IP_ADDRESS>/pub/rhel6/dvd  #IP_ADDRESS of FTP server
    enabled=1
    gpgcheck=0

    :wq  (save and exit) 


              Installing, Removing and Updating Packages using YUM

    # yum install -y packagename
    # yum remove -y packagename
    # yum update -y 
    packagename
One great feature about yum is that instead of updating a single package, you can
list all updates that need to be installed for the system:
    # yum list updates
From this list, you can choose to update packages individually or as a whole. If you
want to install all the updates, you can use the following
    # yum update
you can choose to update packages individually
#yum update packagename

The Yum utility also keeps a list of “groups” that contain a set of packages, making it easier to install sets of packages together 

To display all the available group names
    # yum grouplist
To display information about the group
# yum groupinfo “Remote Desktop Clients”

The following command excludes the paps and the gutenprint-cups packages from the list of those to be installed:
# yum groupinstall “Print Server” -x paps -x gutenprint-cups

To install a particular group
# yum groupinstall “Group Name”

Find the postfix package to install:
# yum search postfix

To find out more information about the postfix package, use the following command:
# yum info postfix

To clear out databases from previously accessed repositories
# yum clean all


Yum server and YUM client configuration has been finished, So Enjoy ...........................!














1 comment: