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
(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
1
|
yum install yum-plugin-downloadonly
|
To install package in RHEL5.x /CentOS 5.x,use below given command
1
|
yum install yum-downloadonly
|
After installation get completed,you can find two new options in yum command
Run the 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)
1
2
3
4
|
[root@localhost ~]# ls -l /var/cache/yum/x86_64/6/base/packages/
total 152
-rw-r--r--. 1 root root 154576 Mar 1 2013 vsftpd-2.2.2-11.el6_4.1.x86_64.rpm
[root@localhost ~]#
|
(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
1
|
yum install --downloadonly vsftpd
|
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:
1
2
3
4
|
[root@localhost ~]# ls -l /var/cache/yum/x86_64/6/base/packages/
total 152
-rw-r--r--. 1 root root 154576 Mar 1 2013 vsftpd-2.2.2-11.el6_4.1.x86_64.rpm
[root@localhost ~]#
|
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
1
2
|
mkdir -p ~/packages
yum install --downloadonly --downloaddir=~/packages wget
|
Check the file,in specified directory
1
2
3
4
|
[root@localhost ~]# ls -l ~/packages/
total 636
-rw-r--r--. 1 root root 494344 Feb 11 16:24 wget-1.12-1.11.el6_5.x86_64.rpm
[root@localhost ~]#
|
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
1
|
yum install yum-utils
|
Download rpm packages with yumdownloader command
Syntax :
1
|
yumdownloader package-name
|
Example: In below given example,we have downloaded the package called zip . With
ls
command, we checked the downloaded file and its location.
1
2
3
4
5
6
7
8
9
10
11
12
|
[root@localhost ~]# yumdownloader zip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centosmirror.go4hosting.in
* extras: centosmirror.go4hosting.in
* updates: centosmirror.go4hosting.in
zip-3.0-1.el6.x86_64.rpm | 260 kB 00:00
[root@localhost ~]#
[root@localhost ~]# ls -lhrt zip-3.0-1.el6.x86_64.rpm
-rw-r--r--. 1 root root 260K Jul 3 2011 zip-3.0-1.el6.x86_64.rpm
[root@localhost ~]#
[root@localhost ~]#
|
Note: yumdownloader command has many option,you can check these option by command
yumdownloader --help
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
[root@localhost ~]# yumdownloader --help
Loaded plugins: fastestmirror
Usage: "yumdownloader [options] package1 [package2] [package..]
Options:
Plugin Options:
Yum Base Options:
-h, --help show this help message and exit
-t, --tolerant be tolerant of errors
-C, --cacheonly run entirely from system cache, don't update cache
-c [config file], --config=[config file]
config file location
-R [minutes], --randomwait=[minutes]
maximum command wait time
-d [debug level], --debuglevel=[debug level]
debugging output level
--showduplicates show duplicates, in repos, in list/search commands
-e [error level], --errorlevel=[error level]
error output level
--rpmverbosity=[debug level name]
debugging output level for rpm
-q, --quiet quiet operation
-v, --verbose verbose operation
-y, --assumeyes answer yes for all questions
--version show Yum version and exit
--installroot=[path]
set install root
--enablerepo=[repo]
enable one or more repositories (wildcards allowed)
--disablerepo=[repo]
disable one or more repositories (wildcards allowed)
-x [package], --exclude=[package]
exclude package(s) by name or glob
--disableexcludes=[repo]
disable exclude from main, for a repo or for
everything
--obsoletes enable obsoletes processing during updates
--noplugins disable Yum plugins
--nogpgcheck disable gpg signature checking
--disableplugin=[plugin]
disable plugins by name
--enableplugin=[plugin]
enable plugins by name
--skip-broken skip packages with depsolving problems
--color=COLOR control whether color is used
--releasever=RELEASEVER
set value of $releasever in yum config and repo files
--setopt=SETOPTS set arbitrary config and repo options
yumdownloader options:
--destdir=DESTDIR destination directory (defaults to current directory)
--urls just list the urls it would download instead of
downloading
--resolve resolve dependencies and download required packages
--source operate on source packages
--archlist=ARCHLIST
only download packages of certain architecture(s)
[root@localhost ~]#
|
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
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:
Post a Comment