Linux Learning - Package Management with RPM/YUM

###Package Management with RPM###
Features:
 1. Compression of packages
 2. SHA-256 hashes are used to sign packages
 3. RPM DB: '/var/lib/rpm' - tracks installed packages, attributes of package files, etc.
 4. 5-Modes of operations:
  a. Install
  b. Uninstall
  c. Upgrade
  d. Query
  e. Verify
 5. Caveat: Does NOT auto-resolve dependencies: Use 'yum'
 6. Caveat: RPM does NOT track non-RPM programs/apps: i.e. '*.tar.gz' || '*.tar.bz2'


Tasks:
 1. Query
  a. 'rpm -qa' - dumps ALL installed packages (RPMs)
  b. 'rpm -qa | grep grep' - 'grep-2.6.3-2.el6.i686'
'grep' - main name of package
'2.6.3-2' - package version
'el6.i686' - RedHat Version & Platform
  c. 'rpm -qi grep' - returns metadata about 'grep' package
  d. 'rpm -ql grep' - enumerates the contents of the package: 'grep'
  e. 'rpm -qf /bin/grep' - enumerates the file's package membership
  f. 'rpm -qd grep' - enumerates the included documentation
  g. 'rpm -qc lftp' - enumerates a package's configuration file(s)
  h. 'rpm -qpi http://192.168.75.101/LinuxCBT/EL-6/Misc/RHEL6/Server/Packages/unix2dos-2.2-35.el6.i686.rpm'


 2. Verify - Verifies file system contents against installed package in RPM DB
Note: Returns: '.' per test performed if the test passed
Note: If test fails, one of the following will be returned:
5(MD5), S(file size), L(symlink), T(mod time), D(device), M(mode), ?(unreadable file), U(user), G(group)
  a. 'rpm -Vvf /bin/grep' - compares: /bin/grep to 'grep' RPM
  b. 'mv /bin/grep /bin/grep.original && touch /bin/grep'
SM5....T.    /bin/grep


 3. Install - Works if package does NOT exist on the system
  a. 'rpm -ivh http://192.168.75.101/LinuxCBT/EL-6/Misc/RHEL6/Server/Packages/unix2dos-2.2-35.el6.i686.rpm'


 4. Upgrade - Installs and/or Upgrades
  a. 'rpm -Uvh http://192.168.75.101/LinuxCBT/EL-6/Misc/RHEL6/Server/Packages/dos2unix-3.1-37.el6.i686.rpm'
  b. 'rpm -Uvh --replacepkgs http://192.168.75.101/LinuxCBT/EL-6/Misc/RHEL6/Server/Packages/grep-2.6.3-2.el6.i686.rpm'
 5. Uninstall
  a. 'rpm -e grep' - checks dependencies and warns where appropriate


 6. Import RedHat RPM GPG Key to confirm package signatures:

  a. 'rpm --import 


###YUM###
Features:
 1. Package management
 2. Auto-dependency resolution
 3. Ability to specify multiple package sources




Tasks:
 1. Mirror 'Packages' directory on local system
  a. 'lftp http://192.168.75.101/LinuxCBT/EL-6/Misc/RHEL6/Packages/'
  b. 'mirror -v'


 2. Run 'createrepo' against: '/var/www/html/RHEL6' - creates sub-directory: 'repodata' and various DB files to serve packages to 'yum' clients
  a. Confirm that 'createrepo' RPM is installed
  b. 'createrepo /var/www/html/RHEL6' - queries ALL 2679 packages and generates a SQLlite DB and ancillary files beneath: 'repodata' dir




 3. Setup first 'yum' client: localhost
  a. '/etc/yum.repos.d/linuxcbtserv2.repo'
  '[linuxcbtserv2]
   name=linuxcbtserv2
   baseurl=http://192.168.75.21/RHEL6 '


 4. Search & Install packages:
  a. 'rpm -e dos2unix unix2dos' - removes both packages
  b. 'yum search unix2dos' - searches for package
  c. 'yum info unix2dos' - returns/dumps/enumerates package metadata
  d. 'yum install unix2dos' - installs the package once
  e. 'yum reinstall unix2dos' - reinstalls package. i.e. '--replacepkgs' with 'rpm'
  f. 'yum -y reinstall unix2dos' - assumes yes when prompted
  g. 'yum history' - returns usage history. i.e. BASH Shell history
  h. 'yum -y erase unix2dos dos2unix' - assumes yes and removes both packages
  i. 'yum deplist lftp' - dependencies and their providers are returned
  j. 'yum localinstall dos2unix-3.1-37.el6.i686.rpm' - Note: The entire file name is indicated


 
 5. Define: 'linuxcbtserv1' as a 'yum' client of 'linuxcbtserv2
 6. Define: 'linuxcbtserv1' as a 'yum' server
  
  a. 'lftp http://192.168.75.101/LinuxCBT/EL-6/Misc/RHEL6/Packages/'
  b. 'mirror -v'
  c. Confirm that 'createrepo' RPM is installed
  d. 'createrepo /var/www/html/RHEL6' - queries ALL 2679 packages and generates a SQLlite DB and ancillary files beneath: 'repodata' dir




 7. Define: 'linuxcbtserv2' as a 'yum' client of 'linuxcbtserv1


Note: This configuration will provide YUM server redundancy via: 2-repo files per 'yum' client


 
'[linuxcbtserv1]
   name=linuxcbtserv1
   baseurl=http://192.168.75.20/RHEL6 '


 8. Test YUM redundancy by enabling/disabling HTTPD(Apache) on both systems and installing/uninstalling packages

你可能感兴趣的:(Linux/RPM/YUM)