Wednesday, September 3, 2014

CentOS/ RedHat : Yum command to download rpm file without installing in linux system

Yum command to download rpm file without installing in linux system

In this tutorial,we will learn how to use yum command to download rpm file without installing in linux system.It was before RHEL 5 arrival, when I used to download the source rpm packages by using up2date -d package-name
Now things are changed,in Red Hat based Operating System above version 5.x . We use the yum command for package management.
In this post,we are sharing two methods to download RPM packages using yum command.

How to download rpm files by using yum command without installing in linux system

We generally use two ways.
(1) By using downloadonly plugin
(2) By using yumdownloader command

Method 1: By using downloadonly plugin with yum

We will first install downloadonly plugin.
To install package in RHEL6.x /CentOS 6.x,use below given command
To install package in RHEL5.x /CentOS 5.x,use below given command
After installation get completed,you can find two new options in yum command
Run the command yum --help for more information.
Downloadonly Plugin Options:
(1) --downloadonly : don’t update, just download
(2) --downloaddir=/path/to/directory : specifies an alternate directory to store packages
Notes:
(1) The downloadonly plugin can be enable/disable from /etc/yum/pluginconf.d/downloadonly.conf file. To enable the downloadonly, in downloadonly.conf file confirm “enabled=1″ (to disable “enabled=0″)
(2) Without using –downloaddir option,files are saved in by-default path /var/cache/yum/. Further from this path,you have to change directory into OS-architecture/channel/package-directory
Example. In this eg. path is /var/cache/yum/x86_64/6/base/packages/ (Reference from CentOS 6.5,arch:x86_64)
(3) This is not applicable to “yum groupinstall”.It is applicable to “yum install” and “yum update”.Whereas, you can use “yum groupinfo” to check the packges in a specific group
(4) By-default it downloads latest available package from yum repository.To download particular package,use the full package name.(example- vsftpd-2.2.2-11.el6)

How to download rpm file by using downloadonly plugin

After installing downloadonly plugin,we are ready to download rpm package.
Example: In this we are downloading vsftpd.By-default it will download to /var/cache/yum directory
Check the path in dir /var/cache/yum . (After this directory path,the location of downloaded package may be differ as per Operating System Version and architecture)
Example:

How to download rpm file in specific directory by using downloadonly plugin

To download rpm file in specific directory, we will use option –downloaddir along with –downloadonly
Example: In this eg. we are creating new directory called packages, for downloading rpm into it.You can specify to any other accessible pre exist directory(like /opt , /tmp , user’s home directory) . Specify the path of destination directory in –downloaddir option
Check the file,in specified directory

Method 2: Using yumdownloader for downloading rpm files without installing it in linux system

By using yumdownloader,we can also download rpm packages from yum repositories without installng it.The yumdownloader command has lots of option.We will specify only few ,which are frequently we use.
With yumdownloader command,the package will be downloaded into the current path of user. (See given below examples)
Install yum-utils package.After installation ,we can use the yumdownloader command
Download rpm packages with yumdownloader command
Syntax :
Example: In below given example,we have downloaded the package called zip . With ls command, we checked the downloaded file and its location.
Note: yumdownloader command has many option,you can check these option by commandyumdownloader --help
Example from my real time experience:
We got a server which was facing low bandwidth problem because of ISP networking issue.
Next day we had Outage for System update including kernel upgrade.Outage period was for 1 hour only.
As per the download speed we were getting,it was not possible to finish the task within 1 hour.Because yum update first download the package and later update into the system.
A day before planned outage,we first downloaded all the rpm packages into the linux system ,into a specific directory with the help of downloadonly method.
Next day,during planned outage,we installed the packages with rpm command.Due to kernel upgrade we also rebooted the server within 1 hour outage time.And task was successfully completed.

No comments: