Axel 是 Linux 下一个不错的轻量级高速下载工具,支持HTTP/FTP/HTTPS/FTPS协议,支持多线程下载、断点续传,且可以从多个地址或者从一个地址的多个连接来下载同一个文件。

大家使用yum下载一些资源的时候,经常会遇到网速不佳或者资源限速,多次下载中断无法正常下载的情况,我们可以使用Axel来支持yum续点下载。

下载安装axel(需要先配置好epel源),gcc环境。

# yum -y install axel
# yum -y install gcc

修改yum配置文件

# sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf
# cd /etc/yum/pluginconf.d/
修改配置文件,添加以下内容。
cat >axelget.conf<<EOF
[main]
enabled=
onlyhttp=
enablesize=
cleanOnException=
EOF # cd /usr/lib/yum-plugins/
修改配置文件,添加以下内容。 cat >axelget.py<<EOF
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=
trymirrornum=-
maxconn=
httpdownloadonly=False
cleanOnException= def init_hook(conduit):
global enablesize,trymirrornum,maxconn,cleanOnException,httpdownloadonly
enablesize = conduit.confInt('main','enablesize',default=)
trymirrornum = conduit.confInt('main','trymirrornum',default=-)
maxconn = conduit.confInt('main','maxconn',default=)
httpdownloadonly=conduit.confBool('main','onlyhttp',default=False)
cleanOnException=conduit.confInt('main','cleanOnException',default=)
return def predownload_hook(conduit):
global enablesize,cleanOnException,httpdownloadonly
preffermirror=""
PkgIdx=
TotalPkg=len(conduit.getDownloadPackages())
for po in (conduit.getDownloadPackages()):
PkgIdx+=
if hasattr(po, 'pkgtype') and po.pkgtype == 'local':
continue
totsize = long(po.size)
ret = False
if totsize <= enablesize:
conduit.info(, "Package %s download size %d less than %d,Skip plugin!" % (po.repo.id,totsize,enablesize))
continue
else:
conduit.info(, "[%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(,"Target already exists,skip to next file!")
continue
localall = "%s %s" % (local,local+".st")
rmcmd = "rm -f %s" % (localall)
curmirroridx =
conduit.info(,"Before we start,clean all the key files")
os.system(rmcmd)
connnum = totsize / enablesize
if connnum*enablesize<totsize:
connnum+=
if connnum > maxconn:
connnum = maxconn
mirrors=[]
mirrors[:]=po.repo.urls
if preffermirror != "":
mirrors[:] = [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 +=
if (curmirroridx > trymirrornum) and (trymirrornum != -):
conduit.info(, "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(, "Execute axel cmd:\n%s" % syscmd)
os.system(syscmd)
time.sleep()
if os.path.exists(local+".st"):
conduit.info(,"axel exit by exception,let's try another mirror")
if cleanOnException:
conduit.info(,"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 (,"try to run rm cmd:%s" % rmcmd)
os.system(rmcmd)
EOF

测试使用:

#yum -y install zabbix-agent
Opening output file /var/cache/yum/x86_64//zabbix/packages/zabbix-agent-4.0.-.el7.x86_64.rpm
Starting download Connection finished ]
Connection finished ]
Connection finished ]
Connection finished ]
Connection finished ]
Connection finished ]
Connection finished ]
[%] [..................................................] [ .8KB/s] [:] 出现多线程下载说明配置OK!

Axel多线程工具安装的更多相关文章

  1. sysbench压力测试工具安装和参数介绍

    一.sysbench压力测试工具简介: sysbench是一个开源的.模块化的.跨平台的多线程性能测试工具,可以用来进行CPU.内存.磁盘I/O.线程.数据库的性能测试.目前支持的数据库有MySQL. ...

  2. MongoDB在Windows下安装、Shell客户端的使用、Bson扩充的数据类型、MongoVUE可视化工具安装和简单使用、Robomongo可视化工具(2)

    一.Windows 下载安装 1.去http://www.mongodb.org/downloads下载,mongodb默认安装在C:\Program Files\MongoDB目录下,到F:\Off ...

  3. [转]hibernateTools工具安装及使用总结(eclipse 3.6)

    转载地址:http://blueblood79.iteye.com/blog/773177 最近项目采用flex+spring+hibernate的框架开发,之前虽说有多年的Java开发经验了,但是一 ...

  4. Java开发工具安装步骤内容如下

    Java开发工具安装步骤内容如下 安装 开发工具 STS 链接下载网址 eclipse 链接下载网址 JDK安装 jdk链接下载地址 Marven环境 marven链接下载地址 Tomcat tomc ...

  5. Linux (Ubuntu12.04) 下开发工具安装和使用

    Linux (Ubuntu12.04) 下开发工具安装和使用 这里讲述的是关于在ubuntu12.04下面安装和使用各种IDE 开发环境和初步使用的知识.说一下背景:很多的开发基本都是在linux操作 ...

  6. 必须使用“角色管理工具”安装或配置Microsoft .NET Framework 3.5 SP1

    在Windows Server 2008下直接安装SQL Server 2008时,会出现如下错误: 必须使用“角色管理工具”安装或配置Microsoft .NET Framework 3.5 SP1 ...

  7. 解决【必须使用“角色管理工具”安装或配置Microsoft .NET Framework 3.5 SP1】的方法

    [摘要:正在Windows Server 2008下间接装置SQL Server 2008时,会涌现以下毛病: 必需应用“脚色治理对象”装置或设置装备摆设Microsoft .NET Framewor ...

  8. VMware中安装CentOS7网络配置静态IP地址,常用配置和工具安装

    VMware中安装CentOS7网络配置静态IP地址,常用配置和工具安装在阿里云开源镜像地址下载镜像Index of /centos/7.2.1511/isos/x86_64/http://mirro ...

  9. 【转】Linux下XenServer管理工具安装

    转载文章 - Linux下XenServer管理工具安装 Xen-Server 6.5 虚拟机安装Linux系统 vmware安装ubuntu12.04嵌套安装xen server(实现嵌套虚拟化) ...

随机推荐

  1. 苏州市java岗位的薪资状况(1)

    8月份已经正式离职,这两个月主要在做新书校对工作.9月份陆续投了几份简历,参加了两次半面试,第一次是家做办公自动化的公司,开的薪水和招聘信息严重不符,感觉实在是在浪费时间,你说你给不了那么多为什还往上 ...

  2. 3.git 远程

    首次拉取代码的话.可以使用 git clone 这个指令 git clone https://github.com/guohongze/adminset.git 带密码方式 git clone htt ...

  3. 多线程(六)多线程同步_SemaPhore信号量

    信号量依然是一种内核同步对象,它的作用在于控制共享资源的最大访问数量 例如:我们有一个服务器,为这服务器创建一个线程池,线程池有五个线程,每个线程处理1个请求.当五个线程都在处理请求时,这个线程池己到 ...

  4. day77_10_24分页器

    一.偏移分页器. 在偏移分页器中,limit代表的是一次性显示的条数,而offset代表的是他基于开头的偏移量. from rest_framework.pagination import Limit ...

  5. java加密类

    java.security.KeyStore KeyStore ks = KeyStore.getInstance(type); KeyStore ks = KeyStore.getInstance( ...

  6. shell的几个实战脚本例子(欠)

    如何让shell实现 可选择性执行 的功能 巡检内存使用率 批量创建用户 场景:公司想要做测试,需要10000个用户 数据库里查询学生成绩 #如何登录mysql数据库 #如何写sql对数据进行操作 # ...

  7. wcf callback在主线程被调用

    记得当时往wcf迁移了部分service以后,tester发现有时候系统会没有任何反应,cpu占用倒是没有问题,可就是做不了事情. 感觉是哪里死锁了,但也不是每次都能再现,后来发现如果把callbac ...

  8. centos 安装python3.7

    先安装依赖包: yum -y install bzip2 bzip2-devel ncurses openssl openssl-devel openssl-static xz lzma xz-dev ...

  9. Shell基本运算符之字符串运算符

    Shell基本运算符 1.字符串运算符 常用的字符串运算符 运算符 说明 例子 = 检测两字符串是否相等,相等返回true [ $a = $b ] != 检测两个字符串是否部相等,不相等返回true ...

  10. 尽解powershell的workflow

    尽解powershell的workflow -------1[简介]--------- Microsoft .NET Framework 4.0 发布于2010年4月左右..net4 的新特性,是并行 ...