admin管理员组

文章数量:1551709

对于在 Linux 的下载工具而言,比较常用的就是 wget 或者 curl,吾也一直用 wget 的方式进行网络上的资源下载。偶然发现了 axel 这个支持多线程的下载工具,试用了几次之后,发现网络文件的下载速度提交了很多,决定将常用的下载工具替换为 axel。

axel是一个多线程分段下载工具,可以从ftp或http服务器进行下载。

1 安装

1、Linux 安装
CentOS 中安装 axel,axel 系统不自带,且 Yum 源也没有 axel 的包,需要从网络中下载。
可以在 https://centos.pkgs/ ,  http://pkgs.repoforge/axel/ 搜索找到并下载安装,下载rpm包安装。

项目地址:https://github/axel-download-accelerator/axel

$ wget http://download-ib01.fedoraproject/pub/epel/7/x86_64/Packages/a/axel-2.4-9.el7.x86_64.rpm
$ rpm -ivh axel-2.4-9.el7.x86_64.rpm

更多版本: 

RPM resource axel

 yum install axel -y

2、macOS 安装
使用 brew 安装

$ brew install axel

源码安装

wget https://github/axel-download-accelerator/axel/releases/download/v2.17.10/axel-2.17.10.tar.xz
tar -xvf axel-2.17.10.tar.xz
cd axel-2.17.10
./configure && make && make install

 在该目录下就有axel

2 选项参数

--max-speed=x , -s x         # 最高速度x
--num-connections=x , -n x   # 连接数x
--output=f , -o f            # 下载为本地文件f
--search[=x] , -S [x]        # 搜索镜像
--header=x , -H x            # 添加头文件字符串x(指定 HTTP header)
--user-agent=x , -U x        # 设置用户代理(指定 HTTP user agent)
--no-proxy , -N             # 不使用代理服务器
--quiet , -q                # 静默模式
--verbose ,-v               # 更多状态信息
--alternate , -a            # Alternate progress indicator
--help ,-h                  # 帮助
--version ,-V               # 版本信息

详细参数:   

--max-speed=x, -s x

指定最大下载速度。

 --num-connections=x, -n x

指定链接的数量。

 --output=x, -o x

指定下载的文件在本地保存的名字。如果指定的参数是一个文件夹,则文件会下载到指定的文件夹下。

--search[=x], -S[x]

Axel将会使用文件搜索引擎来查找文件的镜像。缺省时用的是filesearching。可以指定使用多少个不同的镜像来下载文件。
检测镜像将会花费一定的时间,因为程序会测试服务器的速度,以及文件存在与否。

--no-proxy, -N

不使用代理服务器来下载文件。当然此选项对于透明代理来说无意义。

--verbose

如果想得到更多的状态信息,可以使用这个参数。

--quiet, -q

不向标准输出平台(stdout)输入信息。

--alternate, -a

指定这个参数后将显示一个交替变化的进度条。它显示不同的线程的进度和状态,以及当前的速度和估计的剩余下载时间。

--header=x, -H x

添加HTTP头域,格式为“Header: Value”。

--user-agent=x, -U x

有些web服务器会根据不同的User-Agent返回不同的内容。这个参数就可以用来指定User-Agent头域。缺省时此头域值包括“Axel”,它的版本号以及平台信息。

--help, -h

返回参数的简要介绍信息。

--version, -V

显示版本信息。

 至少要制定一个参数,如果是FTP下载的话,可以指定通配符进行下载, 程序会自行解析完整的文件名。可以指定多个URL进行下载,但是程序不会区分这些URL是否为同一个文件,换而言之,同一个URL指定多次,就会进行多次的下载。

3 下载测试

在同一台服务器上用官方的 CentOS Minimal ISO 镜像,分别用 wget 和 axel 做一个下载测试,文件大小 900M + 。

$ wget http://mirror.sfo12.us.leaseweb/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso

结果:
wget 下载用时 31s。

$ axel -n 20 http://mirror.sfo12.us.leaseweb/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso

结果:
axel 下载用时 12s。

用axel下载东西时,容易出现 Too many redirects. 的错误,则使用最新版本即可。因为github强制使用https,axel会跳转到80端口,这样造成了死循环,github上面的最新版axel已经解决了这个问题。

===============aria2==============================

https://github/aria2/aria2

aria2

  • 优点:比较全能,HTTP 下载和 BT 下载都有,性能也相当不错,速度不比迅雷慢
  • 缺点:无 UI,需要自备;配置麻烦,上手较难。


 axel与aria2c对比

对比项axelaria2c
支持的下载协议HTTP,HTTPS,FTP,FTPS等HTTP/HTTPS GEET方式, FTP,BitTorrent协议和fast扩展
更改下载文件路径/名称-o-o
限制连接数-n-x, –max-connection-per-server,默认为1
限制下载速度-s 或 –max-speed–max-download-limit,默认不限速
断点续传使用相同的axel命令即可-c
替换进度条-a
从文件获取输入不支持-i,–input-file
下载BiTorrent文件种子和磁力链接不支持支持
下载多个文件不支持-z

 使用对比

用20个连接限制1.5M(默认的下载单位为Kb,1.5M=1500000kb)的速度下载deepin的镜像文件到/tmp目录下并改名为deepin15.5.iso文件不使用默认的下载进度条

axel -a -n 20 -s 1500000 -o /tmp/deepin15.5.iso  https://mirrors.tuna.tsinghua.edu/deepin-cd/15.5/deepin-15.5-amd64.iso

 用5个连接限速2M(不可使用小数)从含有deepin镜像文件http下载链接的文件中下载到/tmp目录下改名为deepin15.5.iso并要求下载中断之后能够继续下载

aria2c -x 5 --max-download-limit=2M -c -i ~/deepin.txt 

==========================================

mwget 

安装

wget http://jaist.dl.sourceforge/project/kmphpfm/mwget/0.1/mwget_0.1.0.orig.tar.bz2

tar -xjvf mwget_0.1.0.orig.tar.bz2
cd mwget_0.1.0.orig
./configure
make
make install

 mwget比wget速度,实测提升了至少4倍。因为缺省是4个线程,所以快了4倍。

选项是:

Options:
-b, --debug Show the debug message
-c, --count=num Set the retry count to [num], no limit when "0", the default is "99"
-d, --directory=dir Set the local direcotry to [dir], the default is "."
-f, --file=file Rename the file to [file]
-h, --help A brief summary of all the options
-i, --interval=num Set the ftp retry interval to [num] seconds, the default is "5"
-n, --number=num Use [num] connections instead of the default (4)
-r, --referer=URL Include `Referer: [URL]' header in HTTP request.
-t, --timeout=num Set the connection timeout to [num] seconds, the default is "30"
-v, --version Show the version of the mwget and exit
-x, --proxy=URL Set the proxy [URL]

参考资料:

  1. aria2 懒人安装教程
  2. Aria2+WebUI,迅雷倒下之后的代替品
  3. BT trackers 更新项目
  4. Aria2基础上手指南
  5. 解决Aria2 BT下载速度慢没速度的问题
  6. yaaw (国人开发的 Aria2 web-ui)
  7. bt-trackerlist 官方更新地址

本文标签: 多线程神器命令快速axel