Install the Axel plug-in CentOS 5/6 to accelerate yum download

Source: Internet
Author: User
Tags ftp site

Install the Axel plug-in CentOS 5/6 to accelerate yum download

The axel plug-in is a multi-thread download plug-in based on yum. By opening multiple HTTP/FTP connections, you can download an object in multiple parts to accelerate download. This tool is particularly useful for downloading large files. It can be used for CentOS, RHEL, Fedora, and other Linux releases that use yum. The rpm package cannot be found for the time being. You can only compile and install the package. Axel can be used to increase the download speed by several times in a low-speed network environment.

1. Download the rpm package of the axel plug-in

Http://pkgs.repoforge.org/axel/

Use http://pkgs.repoforge.org/axel/axel-2.4-1.el5.rf.x86_64.rpm for centos 5 64-bit Systems

If you use a http://pkgs.repoforge.org/axel/axel-2.4-1.el6.rf.x86_64.rpm for centos 6 64-bit Systems

2 install rpm package rpm-ivh http://pkgs.repoforge.org/axel/axel-2.4-1.el6.rf.x86_64.rpm

You can directly run the command to install

Yum install axel

3. Download the configuration file axelget. conf and axelget. py to yum:
Cd/etc/yum/pluginconf. d/
Wget http://cnfreesoft.googlecode.com/svn/trunk/axelget/axelget.conf

You can also edit it by yourself. The full text is as follows:

[Main]
Enabled = 1
Onlyhttp = 1
Enablesize = 54000
CleanOnException = 1

Cd/usr/lib/yum-plugins/
Wget http://cnfreesoft.googlecode.com/svn/trunk/axelget/axelget.py

You can also edit it by yourself. The full text is as follows:

From yum. plugins import PluginYumExit, TYPE_CORE, TYPE_INTERACTIVE
From urlparse import urljoin
Import OS, time

Requires_api_version = '2. 3'
Plugin_type = (TYPE_CORE, TYPE_INTERACTIVE)

Enablesize = 300000
Try1_num =-1
Maxconn = 10
Httpdownloadonly = False
CleanOnException = 0

Def init_hook (conducting it ):
Global enablesize, try1_num, maxconn, cleanOnException, httpdownloadonly
Enablesize = conducting it. confInt ('main', 'enablesize', default = 30000)
Try1_num = conducting it. confInt ('main', 'try1_num', default =-1)
Maxconn = conducting it. confInt ('main', 'maxconn', default = 10)
Httpdownloadonly = conducting it. confBool ('main', 'onlyhttp', default = False)
CleanOnException = conducting it. confInt ('main', 'cleanonexception', default = 0)
Return

Def predownload_hook (conducting it ):
Global enablesize, cleanOnException, httpdownloadonly
Preffermirror = ""
PkgIdx = 0
TotalPkg = len (conducting it. getDownloadPackages ())
For po in (conducting it. getDownloadPackages ()):
PkgIdx + = 1
If hasattr (po, 'pkgtype') and po. pkgtype = 'local ':
Continue
Totsize = long (po. size)
Ret = False
If totsize <= enablesize:
Conducting it.info (2, "Package % s download size % d less than % d, Skip plugin! "% (Po. repo. id, totsize, enablesize ))
Continue
Else:
Conducting it.info (2, "[% d/% d] OK, we will try to use axel to download this big file: % d" % (PkgIdx, TotalPkg, totsize ))
Local = po. localPkg ()
If OS. path. exists (local ):
If not OS. path. exists (local + ". st "):
Fstate = OS. stat (local)
If totsize = fstate. st_size:
Conducting it.info (2, "Target already exists, skip to next file! ")
Continue
Localall = "% s" % (local, local + ". st ")
Rmcmd = "rm-f % s" % (localall)
Curmirroridx = 0
Conducting it.info (2, "Before we start, clean all the key files ")
OS. system (rmcmd)
Connnum = totsize/enablesize
If connnum * enablesize <totsize:
Connnum + = 1
If connnum> maxconn:
Connnum = maxconn
Mirrors = []
Mirrors [: 0] = po. repo. urls
If preffermirror! = "":
Mirrors [: 0] = [preffermirror]
For url in mirrors:
If url. startswith ("ftp: //") and httpdownloadonly:
Print "Skip Ftp Site:", url
Continue
If url. startswith ("file ://"):
Print "Skip Local Site:", url
Continue
Curmirroridx + = 1
If (curmirroridx> try1_num) and (try1_num! =-1 ):
Conducting it.info (2, "Package % s has tried % d mirrors, Skip plugin! "% (Po. repo. id, try1_num ))
Break
Remoteurl = "% s/% s" % (url, po. remote_path)
Syscmd = "axel-a-n % s-o % s" % (connnum, remoteurl, local)
Conducting it.info (2, "Execute axel cmd: \ n % s" % syscmd)
OS. system (syscmd)
Time. sleep (2)
If OS. path. exists (local + ". st "):
Conducting it.info (2, "axel exit by exception, let's try another mirror ")
If cleanOnException:
Conducting it.info (2, "because cleanOnException is set to 1, we do remove key file first ")
OS. system (rmcmd)
Continue
Elif not OS. path. exists (local): # this mirror may not update yet
Continue
Else:
Ret = True
Preffermirror = url
Break
If not ret:
Conducting it.info (2, "try to run rm cmd: % s" % rmcmd)
OS. system (rmcmd)

Finally, check that plugins = 1 in/etc/yum. conf.

4. test and install the yum-fastestmirror plug-in.
Yum install-y yum-fastestmirror
Note: The axel plug-in can also be used as an independent download tool. When used as an independent download tool, it is applicable to most Linux distributions.
The parameters are as follows:
Generally: axel url (download file address );
Speed limit: add the-s parameter, for example,-s 10240, that is, the number of bytes downloaded per second. Here it is 10 Kb;
Limit connections: add the-n parameter, such as-n 5, to open five connections.

Yum install axel
Yum install yum-presto
Yum install yum-fastestmirror
Yum install yum-metadata-parser
Yum install yum-downloadonly
Yum install yum-priorities

For more YUM tutorials, see the following:

RedHat 6.2 modify yum source in Linux use CentOS source for free

Configure the epel yum Source

Redhat local yum source configuration

Description of yum configuration file

Install yum in RedHat 6.1)

YUM installation and cleaning

Build yum local source on CentOS 6.4

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.