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. CodeForces - 1256C (思维+贪心)

    题意 https://vjudge.net/problem/CodeForces-1256C 有一条宽度为n的河.河的左岸编号为0,右岸编号为n+1.河流上还有m个木制平台,第i个平台的长度为ci(所 ...

  2. 常见的Dos命令大全

    打开cmd: Win键+R  输入cmd; 常用的Dos命令: 1.盘符切换: 2.打开文件目录:   dir 3.清理屏幕:  cls 4.退出: exit 5.查看本机IP地址:ipconfig ...

  3. 14.Java基础_函数/函数重载/参数传递

    Java函数和函数重载 /* 函数定义: public static 返回类型 func(参数){ 方法体: } 函数重载 在调用时,Java虚拟机会通过参数的不同来区分同名的函数 满足: 1.多个函 ...

  4. 在Python中用许多点找到两个最远点的点

    我需要找到距离彼此最远的两个点. 正如屏幕截图所示,我有一个包含其他两个数组的数组.一个用于X,一个用于Y坐标.确定数据中最长线的最佳方法是什么?通过这样说,我需要选择情节中最远的两个点.希望你们能帮 ...

  5. CF798D Mike and distribution

    CF798D Mike and distribution 洛谷评测传送门 题目描述 Mike has always been thinking about the harshness of socia ...

  6. LG4170/BZOJ1260 「CQOI2007」涂色 区间DP

    区间DP 发现可以转化为区间包含转移. 考虑区间\([l,r]\),分为两种情况. \(col[l]=col[r]\) 此时相当于在涂\([l,r-1]\)或\([l+1,r]\)顺带着涂掉 \[f( ...

  7. go 学习笔记之环境搭建

    千里之行始于足下,开始 Go 语言学习之旅前,首先要搭建好本地开发环境,然后就可以放心大胆瞎折腾了. Go 的环境安装和其他语言安装没什么特别注意之处,下载安装包下一步下一步直到完成,可能唯一需要注意 ...

  8. vs code 中配置git go

    { "window.zoomLevel": 1, "editor.fontSize": 15, //"files.autoSave": &q ...

  9. celery分布式任务队列的使用

    一.Celery介绍和基本使用 Celery 是一个 基于python开发的分布式异步消息任务队列,通过它可以轻松的实现任务的异步处理, 如果你的业务场景中需要用到异步任务,就可以考虑使用celery ...

  10. Centos7安装percona-xtrabackup2.4和8.0版本

    Percona XtraBackup是一个基于MySQL的服务器的开源热备份实用程序 ,它不会在备份期间锁定您的数据库.无论是24x7高负载服务器还是低事务量环境,Percona XtraBackup ...