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. Mybatis-plus中的常用注解

    @TableName:数据库表相关 @TableId:表主键标识 @TableField:表字段标识 @TableLogic:表字段逻辑处理注解(逻辑删除) @TableId(type= IdType ...

  2. Jenkins之插件Publish HTML reports的使用

    前提: 下载插件HTML Publisher plugin 一.安装 安装好HTML Publisher plugin之后,会在新建或者编辑项目时,在[增加构建后操作步骤]出现[Publish HTM ...

  3. Tensorflow之MNIST手写数字识别:分类问题(2)

    整体代码: #数据读取 import tensorflow as tf import matplotlib.pyplot as plt import numpy as np from tensorfl ...

  4. python线程类的start()和run()

    start()方法: 开始线程活动. 对每一个线程对象来说它只能被调用一次,它安排对象在一个另外的单独线程中调用run()方法,而非当前所处的线程,当该方法在同一个线程对象中被调用超过一次时,会引入R ...

  5. 全网最新方法:win10下如何安装和配置64位JDK-13

    1.下载JDK-13 下载链接:https://www.oracle.com/technetwork/java/javase/downloads/index.html 2.安装JDK-13 双击下图的 ...

  6. Django views 中的装饰器

    关于装饰器 示例: 有返回值的装饰器:判断用户是否登录,如果登录继续执行函数,否则跳回登录界面 def auth(func): def inner(request, *args, **kwargs): ...

  7. Protobuf 文件导入和生成

    build: protoc -I=$(GOPATH)/pkg/mod/github.com/micro/micro@v1.13.1/api/proto -I /Users/lzy/Git/Learn/ ...

  8. 洛谷P3702 [SDOI2017]序列计数

    题目大意: Alice想要得到一个长度为\(n\)的序列,序列中的数都是不超过\(m\)的正整数,而且这\(n\)个数的和是\(p\)的倍数. Alice还希望,这\(n\)个数中,至少有一个数是质数 ...

  9. 为Azure DevOps Server (TFS) 配置安全访问(HTTPS with SSL)

    Contents 1. 概述 2. HTTP和HTTS比较 支持HTTP和HTTPS两种方式 要求所有连接使用HTTPS 优点: 缺点: 3. 为Azure DevOps Server 配置安全访问 ...

  10. 通过requirements.txt文件创建虚拟环境副本

    1.首先在原来的环境中生成一个需求文件requirements.txt,用于记录所有依赖包及其精确的版本号. (venv) $ pip freeze >requirements.txt 2.创建 ...