原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://werewolftj.blog.51cto.com/1606482/1415174。原作者:ilove_vc

axel插件是基于yum下的一个多线程下载插件,通过打开多个HTTP/FTP连接来将一个文件进行分段下载,从而达到加速下载的目的。对于下载大文件,该工具特别有用。可用于CentOS、RHEL、Fedora等使用yum的Linux发行版。暂时找不到rpm包,只能编译安装。使用Axel可以在低速网络环境里提高数倍的下载速度。

axel 是Linux 命令行下多线程的下载工具,支持断点续传,速度通常情况下是Wget的几倍

官方主页:http://axel.alioth.debian.org/

×××:

1
# curl  -O  https://alioth.debian.org/frs/download.php/3015/axel-2.4.tar.gz

编译安装:

1
2
3
4
5
6
# tar -xvf axel-2.4.tar.gz  && cd axel-2.4
# ./configure --prefix=/usr/local/axel
# make && make install 
导出axel执行路径
# echo 'PATH=/usr/local/axel/bin:$PATH' > /etc/profile.d/axel.sh && source /etc/profile

添加axel man手册查找路径

1
2
# vim /etc/man.config  
MANPATH /usr/local/axel/share/man

常用选项:

1
2
3
4
-n : 指定线程数
-o : 指定另存为目录
-s   :  指定每秒的最大比特数
-q  : 静默模式

Axel插件加速yum下载:

1
2
3
4
5
# wget https://github.com/crook/yum-axelget/archive/v1.0.5.tar.gz  
# tar -xvf v1.0.5 
# cd yum-axelget-1.0.5/
# cp axelget.conf /etc/yum/pluginconf.d/
# cp axelget.py  /usr/lib/yum-plugins/

补充:

下载配置文件axelget.conf与axelget.py到yum里:

cd /etc/yum/pluginconf.d/
wget http://cnfreesoft.googlecode.com/svn/trunk/axelget/axelget.conf

也可以自己编辑,全文如下:

[main]
enabled=1
onlyhttp=1
enablesize=54000
cleanOnException=1

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

也可以自己编辑,全文如下:

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
trymirrornum=-1
maxconn=10
httpdownloadonly=False
cleanOnException=0

def init_hook(conduit):
 global enablesize,trymirrornum,maxconn,cleanOnException,httpdownloadonly
 enablesize = conduit.confInt('main','enablesize',default=30000)
 trymirrornum = conduit.confInt('main','trymirrornum',default=-1)
 maxconn = conduit.confInt('main','maxconn',default=10)
 httpdownloadonly=conduit.confBool('main','onlyhttp',default=False)
 cleanOnException=conduit.confInt('main','cleanOnException',default=0)
 return

def predownload_hook(conduit):
 global enablesize,cleanOnException,httpdownloadonly
 preffermirror=""
 PkgIdx=0
 TotalPkg=len(conduit.getDownloadPackages())
 for po in (conduit.getDownloadPackages()):
  PkgIdx+=1
  if hasattr(po, 'pkgtype') and po.pkgtype == 'local':
   continue
  totsize = long(po.size)
  ret = False
  if totsize <= enablesize:
   conduit.info(2, "Package %s download size %d less than %d,Skip plugin!"  % (po.repo.id,totsize,enablesize))
   continue
  else:
   conduit.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:
     conduit.info(2,"Target already exists,skip to next file!")
     continue
  localall = "%s %s" % (local,local+".st")
  rmcmd = "rm -f %s" % (localall)
  curmirroridx = 0
  conduit.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 > trymirrornum) and (trymirrornum != -1):
    conduit.info(2, "Package %s has tried %d mirrors,Skip plugin!" % (po.repo.id,trymirrornum))
    break
   remoteurl =  "%s/%s" % (url,po.remote_path)
   syscmd = "axel -a -n %s %s -o %s" % (connnum,remoteurl,local)
   conduit.info(2, "Execute axel cmd:\n%s"  % syscmd)
   os.system(syscmd)
   time.sleep(2)
   if os.path.exists(local+".st"):
    conduit.info(2,"axel exit by exception,let's try another mirror")
    if cleanOnException:
     conduit.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:
   conduit.info (2,"try to run rm cmd:%s"  % rmcmd)
   os.system(rmcmd)

最后确认 /etc/yum.conf中plugins=1

4  测试并安装yum-fastestmirror插件
yum install -y yum-fastestmirror
注:axel插件也可以当独立下载工具来使用。当成独立下载工具使用时,适用于绝大部分Linux发行版。
使用参数如下:
一般使用:axel url(下载文件地址);
限速使用:加上 -s 参数,如 -s 10240,即每秒下载的字节数,这里是 10 Kb;
限制连接数:加上 -n 参数,如 -n 5,即打开 5 个连接。

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

转载于:https://blog.51cto.com/as007012/1865422

CentOS 5/6下安装Axel插件加速yum下载相关推荐

  1. linux axel rpm,CentOS 5/6下安装Axel插件加速yum下载

    axel插件是基于yum下的一个多线程下载插件,通过打开多个HTTP/FTP连接来将一个文件进行分段下载,从而达到加速下载的目的.对于下载大文件,该工具特别有用.可用于CentOS.RHEL.Fedo ...

  2. CentOs 6.0 下安装cacti的syslog插件

    CentOs 6.0 下安装cacti的syslog插件 一.软件环境: OS:CentOS 6.0 x86_64 rsyslog rsyslog-mysql syslog-v1.22-2.tgz 监 ...

  3. Centos 7下安装nginx,使用yum install nginx,提示没有可用的软件包(亲测)

    Centos 7下安装nginx,使用yum install nginx,提示没有可用的软件包. 18 (flaskApi) [root@67 flaskDemo]# yum -y install n ...

  4. CentOS 5.1下安装Opensim

    Opensim是什么? Opensim是一个平台,用来架构一个虚拟世界,并支持多个独立的地区连接到一个单一的网络中心. 这是有点类似的网站,任何人都可以运行自己的网络服务器透过互联网联系在一起.它也可 ...

  5. CentOS 6.4下安装中文输入法

    记录CentOS 6.4下安装中文输入法的过程,希望对大家有所帮助. 1.用root登录 ,或su root 2.yum install "@Chinese Support" 3. ...

  6. ubuntu 安装java插件_Ubuntu下安装JAVA插件欣赏精美网页

    感谢cc2.cc的投递. ------------------------------------------------ 记得1998年那时刚接触网络,就被网上那些精美的Java所展现出来的令人炫目 ...

  7. centos 安装mysql-proxy_详解在Centos 5.2下安装最新Mysql Proxy LUA教程

    在Centos 5.2下安装***Mysql Proxy LUA教程是本文要介绍的内容,主要是来了解Mysql Proxy LUA的安装过程,文章中有很详细的讲解,具体内容来看本文详解. mysql ...

  8. Ubuntu或Linux下安装flash插件

    Ubuntu或Linux下安装flash插件 在Linux系统中,有时候我们使用浏览器浏览某个网站的时候,你会发现无法播放视频或者一些动态图,这都是因为系统没有安装 flash插件所导致的,下面介绍在 ...

  9. CentOS 6.4下安装和配置Samba - 行知小筑 - 51CTO技术博客

    CentOS 6.4下安装和配置Samba - 行知小筑 - 51CTO技术博客

最新文章

  1. qt发布后 mysql数据库_qt发布后 mysql数据库
  2. bootstrap datepicker Uncaught TypeError: Cannot call method 'split' of undefined问题
  3. linux内核头文件 cdev.h 解析
  4. TypeError: pyqtSignal must be bound to a QObject
  5. ie浏览器网页版进入_IE浏览器打开网页提示无法打开Internet站点的解决办法
  6. RabbitMQ 最新版安装 (Linux环境)
  7. php 增加mysql 索引,【PHP】为什么 MySQL 添加索引后就可以提高查询速度
  8. python request处理_python requests异常处理
  9. 天天 Java、C/C++,可这五种编程语言你知道吗?
  10. [鸟哥linux视频教程整理]03_03_bash特性详解续
  11. win10使用navicat管理数据库
  12. (转)Top Ten Web Hacking Techniques of 2011
  13. 向爸爸借了500,向妈妈借了500,买了双皮鞋用了970。剩下30元,还爸爸10块,还妈妈10块,自己剩下了10块,欠爸爸490,欠妈妈490,490+490=980。加上自己的10块=990。还有1
  14. 几种常用网络传输协议
  15. watir 基础知识
  16. 网络与信息安全应急处置预案
  17. Windows简单TCPIP服务
  18. ARM的Trustzone是怎样保证硬件安全的
  19. html和js画圣诞树图片,基于JS2Image实现圣诞树代码
  20. 上海亚商投顾:两市震荡引分化 汽车产业链获青睐

热门文章

  1. 【Oracle】创建用户
  2. main()如果返回0,则代表程序正常退出,返回非零代表程序异常退出。
  3. 解决pycharm在ubuntu下搜狗输入法一直固定在左下角的问题
  4. dubbo 解决既是消费者又是提供者 Duplicate application configs 的问题
  5. eclipse 中提示tomcat 的端口被占用了 后的最快捷解决方法
  6. win11的附件在哪 windows11附件的查看方法
  7. Python基础-数据类型转换,默认参数,关键字参数
  8. mybatis开启二级缓存和懒加载,类型别名,类都简称
  9. java scjp 试题_JAVA认证历年真题:SCJP考试真题和解析
  10. mysql免费框架_MySQL(ORM框架)