棄用 wget, 擁抱多線程下載 axel


0x00 事件

對於在 Linux 的下載工具而言,比較常用的就是 wget 或者 curl,吾也一直用 wget 的方式進行網絡上的資源下載。偶然發現了 axel 這個支持多線程的下載工具,試用了幾次之后,發現網絡文件的下載速度提交了很多,決定將常用的下載工具替換為 axel。

0x01 安裝

1、Linux 安裝
CentOS 中安裝 axel,axel 系統不自帶,且 Yum 源也沒有 axel 的包,需要從網絡中下載。
可以在 https://centos.pkgs.org/ ,搜索找到並下載安裝。

$ wget http://download-ib01.fedoraproject.org/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

2、macOS 安裝
使用 brew 安裝

$ brew install axel

0x02 選項參數

--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               # 版本信息

0x03 下載測試

在同一台服務器上用官方的 CentOS Minimal ISO 鏡像,分別用 wget 和 axel 做一個下載測試,文件大小 900M + 。

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

結果:
wget 下載用時 31s。

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

結果:
axel 下載用時 12s。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM