命令行的"迅雷",这样用会更香

王通老师在他的 "基因学苑" 公众号,发表过一篇《命令行的“迅雷”,提升百倍以上下载速率》的文章,给我们简单介绍了 axel 这个命令行下多线程下载的利器。本公众号也有幸转载过,但在实际使用中 axel 还是有几点不为人知小秘密,今天来聊一下。

直接安装

有源的情况下,axel 在 CentOS 可以通过 yum 的方式直接安装:
yum install -y axel
没有源的情况下,在 CentOS 6/7 中可以先添加 Epel 源再安装:
yum install epel-release
yum install axel
或者通过 rpm 的方式安装:
rpm -ivh ftp://fr2.rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/axel-2.4-1.el6.rf.x86_64.rpm

对于 Debian/Ubuntu 中安装 Axel,有源的情况可以参考下面的安装方式;无源情况下的安装可以参考源码或者其他的安装方式,这里不细说:

apt-get install axel


源码安装

axel 的源码是托管在 Github 上的,我们可以下载它的源码进行手动安装。

源码下载,启动安装
下载源码,并生成用于 axel 安装的 configure 可执行文件:
$ git clone https://github.com/axel-download-accelerator/axel.git
cd axel/
$ autoreconf -i
Copying file ABOUT-NLS
Creating directory build-aux
Copying file build-aux/config.rpath
...
Copying file po/Rules-quot
configure.ac:13: error: Autoconf version 2.69 or higher is required
configure.ac:13: the top level
autom4te: /usr/bin/m4 failed with exit status: 63
aclocal: autom4te failed with exit status: 63
autoreconf: aclocal failed with exit status: 63

安装 Autoconf-2.69 依赖
$ wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
$ tar zvxf autoconf-2.69.tar.gz
cd autoconf-2.69
$ ./configure --prefix=/usr/local/software/autoconf-2.69
$ make && make install
export PATH=/usr/local/software/autoconf-2.69/bin:$PATH  # 也可以把 autoconf 添加到 ~/.bashrc

安装 gettext-devel 依赖
$ autoreconf -i          
Can't exec "autopoint": No such file or directory at /usr/share/autoconf/Autom4te/FileUtils.pm line 345.
autoreconf: failed to run autopoint: No such file or directory
autoreconf: autopoint is needed because this package uses Gettext
33481196-0ec4-4327-9b19-b31e5034ab96.png

可以通过 yum 安装 gettext-devel 解决:
$ yum install -y gettext-devel

安装 autoconf-archive 依赖
$ autoreconf -i 
$ ./configure --prefix=/usr/local/software/axel
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
......
checking dependency style of gcc... (cached) gcc3
checking for gcc option to accept ISO C99... -std=gnu99
./configure: line 5358: syntax error near unexpected token `git-directory'
./configure: line 5358: `AX_IS_RELEASE(git-directory)'

解决方法一,通过 yum 安装 autoconf-archive
[root@ecs-steven ~]# yum install autoconf-archive
解决方法二,手动安装 autoconf-archive
$ wget http://mirrors.nju.edu.cn/gnu/autoconf-archive/autoconf-archive-2019.01.06.tar.xz
$ tar xvJf autoconf-archive-2019.01.06.tar.xz
cd autoconf-archive-2019.01.06
$ ./configure --prefix=/usr/local/software/autoconf-archive-2019.01.06
$ make 
$ make install

注意:

  1. 如果你使用 --prefix 指定了 autoconf-archive 的安装路径,在安装 axel 的时候需要额外指定 autoconf-archive 的 m4 文件路径:

$ autoreconf -i -I/usr/local/software/autoconf-archive-2019.01.06/share/aclocal 
  1. 我在 CentOS 6.5 下使用了自定义的 autoconf-archive 的安装路径,在 configure 时总是提示 invalid date 错误,make 的时候更是直接抛出 axel_gettime 函数错误:

$ autoreconf -i -I/usr/local/software/autoconf-archive-2019.01.06/share/aclocal 
$ ./configure --prefix=/usr/local/software/axel
......
checking for PTHREAD_PRIO_INHERIT... yes
date: invalid date `2019-08-29T19:39:14Z'
configure: creating ./config.status
....

$ make 
...
cc1: warnings being treated as errors
src/axel.c: In function ‘axel_gettime’:
src/axel.c:720: error: declaration of ‘time’ shadows a global declaration
/usr/include/time.h:186: error: shadowed declaration is here
At top level:
cc1: error: unrecognized command line option "-Wno-suggest-attribute=format"
make[2]: *** [src/axel.o] Error 1
make[2]: Leaving directory `/usr/local/src/axel'

make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/axel'
make: *** [all] Error 2
尝试了各种方法后,直到我用自己安装的 gcc-4.8.5 替换系统默认的 gcc-4.4.7 后,才成功解决这个问题,个中具体原因熟悉 C 的童鞋可以研究下。
$ ./configure --prefix=/usr/local/software/axel CC=/usr/local/software/gcc-4.8.5/bin/gcc


安装 txt2man 依赖
$ autoreconf -i -I/usr/local/autoconf-archive-2019.01.06/share/aclocal 
$ ./configure --prefix=/usr/local/software/axel CC=/usr/local/software/gcc-4.8.5/bin/gcc
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
......
configure: creating ./config.status
config.status: creating Makefile
config.status: creating po/Makefile.in
config.status: WARNING:  'po/Makefile.in.in' seems to ignore the --datarootdir setting
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing default-1 commands
config.status: creating po/POTFILES
config.status: creating po/Makefile

$ make
make  all-recursive
make[1]: Entering directory `/usr/local/src/axel'
Making all in po
...
/bin/sh: line 1: txt2man: command not found
make[2]: *** [doc/axel.1] Error 1
make[2]: Leaving directory `/usr/local/src/axel'

make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/axel'
make: *** [all] Error 2
解决方法一, yum 一键安装。
yum install txt2man
解决方法二,源码手动安装。
$ wget http://mvertes.free.fr/download/txt2man-1.5.6.tar.gz
$ tar zvxf txt2man-1.5.6.tar.gz                          
$ cp -r txt2man-1.5.6 /usr/local/software               # txt2man 无需安装,直接解压即可
export PATH=/usr/local/software/txt2man-1.5.6:$PATH   # 你也可以把它添加到 ~/.bashrc

继续安装 axel

上面的依赖都解决后,我们就可以继续后面的 axel 安装了。

$ make 
$ make install
9a9ac7b2-65ed-4ece-9eca-b4ea919f7154.png


Too many redirects

如果你在使用 axel 下载 https 相关的资源,你可能会发现:

f6b30aba-6cc7-460f-b146-70a97eff4387.png

这是因为,CentOS 中通过 yum 方式安装的 axel 默认版本为 2.4,而该版本的 axel 对于 h 开头的链接会默认使用 http(port 80) 的协议进行下载,对于 f 开头的链接会默认使用 ftp 的协议,如果 axel 遇上了强制使用 https 的网站链接,就会出现这个反复重定向的错误。

针对这种情况,请参考上面的 "源码安装" 安装 axel 的最新版本!安装完了以后,即可以下载 https 相关的资源。

2c5f1a8e-5b93-43cb-b21a-95dfc5d14295.png
阿里云 1Mbps 的 ECS 上闲时的 axel 下载速度


——The  End——



往期精彩:
e27195f4-690c-4739-8983-d58503aabaa0.png

本文分享自微信公众号 - 生信科技爱好者(bioitee)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值