Axel多线程工具安装
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多线程工具安装的更多相关文章
- sysbench压力测试工具安装和参数介绍
一.sysbench压力测试工具简介: sysbench是一个开源的.模块化的.跨平台的多线程性能测试工具,可以用来进行CPU.内存.磁盘I/O.线程.数据库的性能测试.目前支持的数据库有MySQL. ...
- MongoDB在Windows下安装、Shell客户端的使用、Bson扩充的数据类型、MongoVUE可视化工具安装和简单使用、Robomongo可视化工具(2)
一.Windows 下载安装 1.去http://www.mongodb.org/downloads下载,mongodb默认安装在C:\Program Files\MongoDB目录下,到F:\Off ...
- [转]hibernateTools工具安装及使用总结(eclipse 3.6)
转载地址:http://blueblood79.iteye.com/blog/773177 最近项目采用flex+spring+hibernate的框架开发,之前虽说有多年的Java开发经验了,但是一 ...
- Java开发工具安装步骤内容如下
Java开发工具安装步骤内容如下 安装 开发工具 STS 链接下载网址 eclipse 链接下载网址 JDK安装 jdk链接下载地址 Marven环境 marven链接下载地址 Tomcat tomc ...
- Linux (Ubuntu12.04) 下开发工具安装和使用
Linux (Ubuntu12.04) 下开发工具安装和使用 这里讲述的是关于在ubuntu12.04下面安装和使用各种IDE 开发环境和初步使用的知识.说一下背景:很多的开发基本都是在linux操作 ...
- 必须使用“角色管理工具”安装或配置Microsoft .NET Framework 3.5 SP1
在Windows Server 2008下直接安装SQL Server 2008时,会出现如下错误: 必须使用“角色管理工具”安装或配置Microsoft .NET Framework 3.5 SP1 ...
- 解决【必须使用“角色管理工具”安装或配置Microsoft .NET Framework 3.5 SP1】的方法
[摘要:正在Windows Server 2008下间接装置SQL Server 2008时,会涌现以下毛病: 必需应用“脚色治理对象”装置或设置装备摆设Microsoft .NET Framewor ...
- VMware中安装CentOS7网络配置静态IP地址,常用配置和工具安装
VMware中安装CentOS7网络配置静态IP地址,常用配置和工具安装在阿里云开源镜像地址下载镜像Index of /centos/7.2.1511/isos/x86_64/http://mirro ...
- 【转】Linux下XenServer管理工具安装
转载文章 - Linux下XenServer管理工具安装 Xen-Server 6.5 虚拟机安装Linux系统 vmware安装ubuntu12.04嵌套安装xen server(实现嵌套虚拟化) ...
随机推荐
- fiddler---Fiddler弱网测试
无论是做web端还是app端的测试,我们都需要对弱网进行测试,对于弱网方法有很多种,如:Fiddler模拟弱网,控制电脑的网速等,今天介绍下Fiddler如何进行测试弱网 什么是弱网 弱网看字面意思就 ...
- Python入门基础学习(函数)
Python基础学习笔记(三) 函数的概念: 所谓函数,就是把具有独立功能的代码块组织为一个小模块,在需要的时候调用 函数的使用包含两个步骤: 1.定义函数 --封装独立的功能 2.调用函数 --享受 ...
- TestNG参数化测试之Excel读取数据
1.新建Excel文档,准备好测试数据 在当前工程的resources目录下,新建文件名为testdata的Excel文档 打开Excel,将当前sheet重命名为calculator,构造num1. ...
- [转] 构建Docker镜像两种方式的比较-Dockerfile方式和S2I方式
原文地址:https://www.cnblogs.com/tianshifu/p/8127837.html 前言 写Dockerfile是构建Docker镜像最通常的方式,接触过Docker的童鞋多少 ...
- Python学习笔记5 【转载】基本矩阵运算_20170618
需要 numpy 库支持 保存链接 http://www.cnblogs.com/chamie/p/4870078.html 1.numpy的导入和使用 from numpy import *;#导入 ...
- 剑指Offer-16.合并两个排序的链表(C++/Java)
题目: 输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则. 分析: 可以用一个新的节点,来去比较两个单调递增的链表当前节点的值,如果p1当前的值小于p2,则新 ...
- 卷积核filter和kernal的区别
在一堆介绍卷积的帖子中,这篇特别之处在于很萌的示例配色,令人眼前一亮,当然直观也是很直观滴,保证了能在昏昏欲睡见周公子前看完. https://towardsdatascience.com/types ...
- luoguP2852 [USACO06DEC]Milk Patterns
题意 显然如果有一个子串出现过\(k\)次,那么它必定是一个至少长为k的后缀序的\(LCP\),求出所有相邻的长为\(k-1\)的\(height\)数组的最小值,在其中取最大值即可 code: #i ...
- ionic4 组件调用的坑
我们再开发过程中很多模块做成组件,那么调用的时候则需把module.ts中的引入去掉,如下红色框框:
- Manthan, Codefest 18 (rated, Div. 1 + Div. 2) E bfs + 离线处理
https://codeforces.com/contest/1037/problem/E 题意 有n个人,m天,在第i天早上,x和y会成为朋友,每天晚上大家都要上车,假如一个人要上车那么他得有至少k ...