• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • Life always offers you a second chance ... Its called tomorrow !!!

    Tuesday, November 18, 2014

    How to use yum locally without internet connection using cache?

    yum is an short abbreviation for Yellowdog Updater Modified

    What is yum?

    yum  is  an  interactive, rpm based, package manager. It can automatically perform system updates, including dependency analysis and obsolete processing based on "repository" metadata. It can also perform installation of  new  packages,  removal  of  old packages and perform queries on the installed and/or available packages among many other commands/services.

    How to use yum without internet connection?

    By default, yum deletes downloaded data files when they are no longer needed after a successful operation. This minimizes the amount of storage space that yum uses.

    However, you can enable caching, so that the package files downloaded by yum stay in cache directories. By using cached data, you can carry out certain operations without a network connection, you can also copy packages stored in the caches and reuse them elsewhere

    yum stores temporary files in the /var/cache/yum/$basearch/$releasever/directory, where $basearch and $releasever are Yum variables refering to base architecture of the system and the release version of Red Hat Enterprise Linux.

    You can find the values for the $basearch and $releasever variables in the output of the yum version command.
    # yum version
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Warning: RPMDB altered outside of yum.
    Installed: 6/i386                  1143:95f0fe20d81af24850e6364a81367b66c9f4a1e2
    Group-Installed: yum                 14:3224f04a082a6cc0af5bc42667a6c5315ca35e96

    Enabling the Caches

    To retain the cache of packages after a successful installation, add the following text to the [main] section of /etc/yum.conf.
    keepcache = 1 Once you enabled caching, every yum operation may download package data from the configured repositories.
    To download and make usable all the metadata for the currently enabled yum repositories, type:
    # yum makecache
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Loading mirror speeds from cached hostfile
     * base: mirrors.ispros.com.bd
     * extras: mirror.digistar.vn
     * updates: mirror.vietoss.com
    base                                                     | 3.7 kB     00:00
    base/group_gz                                            | 214 kB     00:11
    base/filelists_db                                        | 5.1 MB     07:31
    base/primary_db                                          | 3.6 MB     08:58
    base/other_db                                            | 2.2 MB     05:25
    extras                                                   | 3.3 kB     00:00
    extras/filelists_db                                      |  31 kB     00:00
    extras/prestodelta                                       |   78 B     00:00
    extras/primary_db                                        |  28 kB     00:00
    extras/other_db                                          |  35 kB     00:01
    updates                                                  | 3.4 kB     00:00
    updates/filelists_db                                     | 614 kB     00:08
    updates/prestodelta                                      |  58 kB     00:00
    updates/primary_db                                       | 800 kB     00:10
    updates/other_db                                         | 6.0 MB     00:58
    Metadata Cache Created

    This is useful if you want to make sure that the cache is fully up to date with all metadata. To set the time after which the metadata will expire, use the metadata-expire setting in /etc/yum.conf.

    From man page
    makecache: Is used to download and make usable all the metadata for the currently enabled yum repos.

    Using yum in Cache-only Mode

    To carry out a yum command without a network connection, add the -C command-line option. With this option, yum proceeds without checking any network repositories, and uses only cached files. In this mode, yum may only install packages that have been downloaded and cached by a previous operation.
    # yum -C list glibc
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Installed Packages
    glibc.i686                         2.12-1.132.el6                          @base
    Available Packages
    glibc.i686                         2.12-1.149.el6                          base

    So as you see we have an update for glibc package which we can install with out internet connection using the cache by using the below command
    # yum -C update glibc

    Clearing the yum Caches

    It is often useful to remove entries accumulated in the /var/cache/yum/ directory. If you remove a package from the cache, you do not affect the copy of the software installed on your system. To remove all entries for currently enabled repositories from the cache, type the following as a root:
    # yum clean all
    I hope the tutorial was helpful.

    Related Articles:
    YUM with APACHE configuration
    Existing lock /var/run/yum.pid: another copy is running

    Follow the below links for more tutorials

    How to configure iscsi target using Red Hat Linux
    What are the different types of Virtual Web Hosting in Apache
    Comparison and Difference between VMFS 3 and VMFS 5
    How to configure PXE boot server in Linux using Red Hat 6
    How to secure Apache web server in Linux using password (.htaccess)
    How to register Red Hat Linux with RHN (Red Hat Network )
    15 tips to enhance security of your Linux machine
    How does a DNS query works when you type a URL on your browser?
    How to create password less ssh connection for multiple non-root users
    How to create user without useradd command in Linux
    How to give normal user root privileges using sudo in Linux/Unix
    How to do Ethernet/NIC bonding/teaming in Red Hat Linux
    How to install/uninstall/upgrade rpm package with/without dependencies
    Why is Linux more secure than windows and any other OS
    What is the difference between "su" and "su -" in Linux?


    Post a Comment