Method One: Yum
The Yum command itself can be used to download an RPM package, and the standard Yum command provides a--downloadonly (download only) option to achieve this goal.
$ sudo yum install--downloadonly <package-name>
By default, a downloaded RPM package is saved in the following directory:
/var/cache/yum/x86_64/[centos/fedora-version]/[repository]/packages
The [repository] above indicates the name of the source repository for the download package (for example, base, fedora, updates)
If you want to download a package to a specified directory (for example,/tmp):
$ sudo yum install--downloadonly--downloaddir=/tmp <package-name>
Note that if the downloaded package contains any dependencies that are not satisfied, Yum will download all the dependency packages, but will not be installed.
Another important thing is that in Centos/rhel 6 or earlier versions, you need to install a separate Yum plug-in (named Yum-plugin-downloadonly) to use the--downloadonly command option:
$ sudo yum install yum-plugin-downloadonly
If you do not have the plugin, you will get the following error when using Yum:
Command line error:no such option:--downloadonly
Method Two: Yumdownloader
Another way to download the RPM package is through a dedicated package download tool--yumdownloader. This tool is a subset of the Yum Toolkit (which contains a help kit for Yum package management).
$ sudo yum install yum-utils
Download an RPM Package:
$ sudo yumdownloader <package-name>
The downloaded package is saved in the current directory. You need to use root permissions because Yumdownloader will update the package index files during the download process. Unlike the Yum command, any dependency pack is not downloaded.
Http://ask.xmodulo.com/yum-download-rpm-package.html