什麼,wget下載很慢?試試看多線程的mwget命令

2021-12-29 生信技能樹

前面我們提到過,參考:使用ebi資料庫直接下載fastq測序數據 , 偶爾會遇到spera提示:ascp: failed to authenticate, exiting. 以及Session Stop (Error: failed to authenticate),其實這個是無解的, 所以只能說放棄 aspera高速下載了,反正就兩三個樣品,直接wget也行。

但是呢,wget就會遇到另外一個問題,下載速度實在是不可恭維,恰好前些天學徒也遇到了一個資料庫下載龜速問題,他通過多線程的mwget命令解決了問題。

下載和安裝

wget 下載有點兒慢,有時候沒得科學上網,慢上加慢了。

首先是下載解壓安裝一條龍:

wget http://jaist.dl.sourceforge.net/project/kmphpfm/mwget/0.1/mwget_0.1.0.orig.tar.bz2
tar -jxvf mwget_0.1.0.orig.tar.bz
cd mwget_0.1.0.orig
/.configure

這時候configure 可能會發生報錯:

configure: error: Your intltool is too old.  You need intltool 0.35.0 or later.

切換一下環境,嘗試用conda 安裝這個 intltool :

conda activate mess
conda install intltool

再次編譯安裝:

./configure
make

'make 又發生報錯了:

ttpplugin.cpp:149:14: error: 『strstr』 was not declared in this scope
  149 |   filename = strstr(filename, "filename=");
      |              ^~~~~~
httpplugin.cpp:149:14: note: 『strstr』 is defined in header 『<cstring>』; did you forget to 『#include <cstring>』?
httpplugin.cpp:151:16: error: 『strlen』 was not declared in this scope
  151 |    filename += strlen("filename=");
      |                ^~~~~~
httpplugin.cpp:151:16: note: 『strlen』 is defined in header 『<cstring>』; did you forget to 『#include <cstring>』?
make[2]: *** [Makefile:385: httpplugin.o] Error 1
make[2]: Leaving directory '/home/data/yzpeng/3.biosoft/other_soft/mwget_0.1.0.orig/src'
make[1]: *** [Makefile:323: all-recursive] Error 1
make[1]: Leaving directory '/home/data/yzpeng/3.biosoft/other_soft/mwget_0.1.0.orig'

參考:https://blog.csdn.net/lihengchang0212/article/details/89946235

主要對兩個文件修改一下:

make[2]: *** [Makefile:385: httpplugin.o] Error 1
Leaving directory '/home/data/yzpeng/3.biosoft/other_soft/mwget_0.1.0.orig/src'
make[1]: *** [Makefile:323: all-recursive] Error 1
make[1]: Leaving directory '/home/data/yzpeng/3.biosoft/other_soft/mwget_0.1.0.orig'

在httpplugin.cpp頭文件中添加:

#include <string.h>
#include <string>
using std::string;

又報錯了,接著來:

make[2]: *** [Makefile:385: ftpplugin.o] Error 1
make[2]: Leaving directory '/home/data/yzpeng/3.biosoft/other_soft/mwget_0.1.0.orig/src'

(後面還經歷了幾次報錯,這裡統一記錄一下)在ftpplugin.cpp, downloader.cpp添加一下:

#include <string.h>
#include <string>
using std::string;

終於成功了:

...
file=`echo zh_CN | sed 's,.*/,,'`.gmo \
  && rm -f $file && /home/yzpeng/miniconda3/envs/mess/bin/msgfmt -o $file zh_CN.po
make[2]: Leaving directory '/home/data/yzpeng/3.biosoft/other_soft/mwget_0.1.0.orig/po'
make[2]: Entering directory '/home/data/yzpeng/3.biosoft/other_soft/mwget_0.1.0.orig'
make[2]: Leaving directory '/home/data/yzpeng/3.biosoft/other_soft/mwget_0.1.0.orig'
make[1]: Leaving directory '/home/data/yzpeng/3.biosoft/other_soft/mwget_0.1.0.orig'

接著make install 又發生了權限錯誤:

make install

...
/usr/bin/install: cannot create regular file '/usr/local/bin/mwget': Permission denied
make[2]: *** [Makefile:315: install-binPROGRAMS] Error 1
make[2]: Leaving directory '/home/data/yzpeng/3.biosoft/other_soft/mwget_0.1.0.orig/src'
make[1]: *** [Makefile:506: install-am] Error 2
make[1]: Leaving directory '/home/data/yzpeng/3.biosoft/other_soft/mwget_0.1.0.orig/src'
make: *** [Makefile:323: install-recursive] Error 1

我們需要把軟體編譯到用戶家目錄的bin 文件夾中:

make install DESTDIR=/home/user/bin

成功了~

~/0.bin
$ bin/mwget 
mwget: missing URL
Usage:  mwget  [Options]... [URL]...

Try `mwget --help` for more options,Thanks!

我們將它放到bin 目錄中:

cd 0.bin
ln -s ../bin/wget .

奇怪啊,為什麼不直接使用conda來安裝多線程的mwget命令?其實如果是原始碼安裝軟體,應該是學習Jimmy老師的視頻:

https://www.bilibili.com/video/BV1cJ411e7UH 生信分析入門環境搭建
1.4萬播放 · 
20彈幕

https://www.bilibili.com/video/BV1ps411M7UZ 生信人應該這樣安裝軟體
1.7萬播放 · 
47彈幕

https://www.bilibili.com/video/BV1XW411d7Bp 生信伺服器配置全攻略
1.3萬播放 · 
67彈幕
``

不管那麼多了,先使用看看!

使用
$ mwget -h
GNU MWget 0.1.0 ,a non-interactive and multiline network retriever of all POSTIX Systems.
Usage:  mwget  [Options]... [URL]...
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]


Mail bug reports and suggestions to <sa@kmlinux.tk><xiao_suo@hotmail.com>
On website bug reports and suggestions to <http://mwget.sourceforge.net/> <http://www.kmlinux.tk/>
We Welcome your BUG REPORT!

其實最主要的參數還是這個 -n,設置多線程下載的數目。

嘗試下載一個annovar 上的數據:

nohup mwget -n 16 --file=hg38_1000g2015aug.zip http://www.openbioinformatics.org/annovar/download/hg38_1000g2015aug.zip &

比較一下速度:

# mwget
Begin to download: hg38_exac03.txt.idx.gz
FileSize: 6.1M
100% [=========================================>===] [6.1M] [1.9M/s]

# wget
hg38_exac03.txt.idx  36%[======>             ]   2.22M   174KB/s    eta 21s

雖然我設置了  -n 16  ,但是並不代表它可以達到16倍的加速哦,正常情況下是174KB/s  ,加速後是 1.9M/s,也是有10倍加速啦,挺滿意的。

相關焦點

  • 4 個 Linux 下最好的命令行下載管理器/加速器
    我們都想要一個超級快速的下載管理器來完成下載儘可能多的任務,以便我們可以節省時間來進一步地工作。有很多可以加速下載的下載管理器和加速器可用(圖形化界面和命令行界面)。所有的下載工具做著同樣的任務,但它們的處理方式和功能是不同的,比如,單線程和多線程、交互和非交互。 在這裡,我們將列出 4 個最好的我們日常工作使用的命令行下載加速器。
  • HTTPie:替代 Curl 和 Wget 的現代 HTTP 命令行客戶端 | Linux 中國
    大多數時間我們會使用 curl 命令或是 wget 命令下載文件或者做其他事。我們以前曾寫過 最佳命令行下載管理器[1] 的文章。你可以點擊相應的 URL 連接來瀏覽這些文章。◈ aria2 – Linux 下的多協議命令行下載工具[2]◈ Axel – Linux 下的輕量級命令行下載加速器[3]◈ Wget – Linux 下的標準命令行下載工具[4]◈ curl – Linux 下的實用的命令行下載工具[5]今天我們將討論同樣的話題。這個實用程序名為 HTTPie。
  • linux常用下載工具
    http://wordpress.org/latest.zip下載指定文件中的url列表wget ‐‐input list-of-file-urls.txt下載指定數字列表的多個文件wget http://example.com/images/{1..20}.jpg下載web
  • Photon 多線程不限速下載軟體
    【軟體名稱】:Photon【安裝環境】:Windows【下載連結
  • aria2 (命令行下載器)實例
    aria2[1] 是一個自由、開源、輕量級多協議和多源的命令行下載工具。
  • 黑客乾貨|命令行/終端下載指令大全
    直接下載:wget http://www.sample-videos.com/video/mp4/big.mp4後臺下載:wget -b http://www.sample-videos.com/video/mp4/big.mp4如果網際網路連接出現中斷,恢復下載:wget -c http
  • [限時特惠] IDM 下載工具 - 經典好用優秀的多線程加速下載利器
    它的全名叫做 Internet Download Manager (網際網路下載管理器),縮寫就是 IDM。IDM 是一款非常經典老牌、功能強大的 Windows 文件多線程下載加速軟體,在電腦玩家間的評價極高,甚至被稱為 HTTP 下載神器!
  • 用powershell下載文件的姿勢你研究過嗎?
    1.Invoke-WebRequest說到使用 PowerShell 下載文件,最先想到的就是 Invoke-WebRequest 命令。可能你有點不熟悉這個名字,它有 3 個別名,分別是 「iwr」、「wget」、「curl」。
  • 多線程下載神器Internet Download Manager(IDM )官方中文免授權版下載
    Internet Download Manager(IDM)是一款國外的多線程下載神器,
  • Redis的keys命令到底有多慢?
    掃描對象是Redis服務中所有的key,想想都很慢對不對?同時執行keys命令的同時,Redis進程將被阻塞,無法執行其他命令,假如超過了哨兵的down-after-milliseconds配置,還會進行主從切換,切換過程中,如果主節點恢復正常,還可能出現腦裂等一系列問題。
  • Python 中用多線程進行多任務處理
    GIL熟悉python的都知道,在C語言寫的python解釋器中存在全局解釋器鎖,由於全局解釋器鎖的存在,在同一時間內,python解釋器只能運行一個線程的代碼,這大大影響了python多線程的性能。而這個解釋器鎖由於歷史原因,現在幾乎無法消除。
  • 一條命令讓腳本幫我安裝MacOS
    最近發現一個很強的項目:myspaghetti/macos-virtualbox一行命令幫你在VirtualBox虛擬機上安裝好Mac Os系統,並且系統是直接從Apple上下載的官方版本,還免去了我們尋找系統鏡像的煩惱.之前也嘗試過用ISO文件安裝,步驟繁瑣,並且安裝好後的系統不知道為什麼十分卡頓.
  • Ractor 下多線程 Ruby 程序指南
    然而,直接解除 GIL 鎖會導致大量默認 GIL 可用的依賴出現問題,在多線程開發中會產生難以預料的線程競爭問題。去年在 RubyConf China 的時候,我問 matz 說 90 年代多核的小型機以及超級計算機已經變得非常普遍了,為什麼會把 Ruby 的多線程設計成這樣呢?
  • C++ 多線程編程
    本文是一篇工程開發方面的文章,算法的落地還是需要工程代碼的依託,比如在雷射雷達感知模塊中如果既包含了傳統點雲處理做障礙物檢測,又使用深度學習做點雲目標識別,往往需要採用多線程並行處理兩個分支,再將輸出結果融合後送入跟蹤模塊,這裡簡單介紹下C++的多線程知識。線程是進程中的一個實體,是被系統獨立分配和調度的基本單位。也就是說線程是CPU可執行調度的最小單位。
  • 2 種從 Linux 終端下載文件的方法 | Linux 中國
    如果你被困在 Linux 終端,比如說在伺服器上,如何從終端下載文件?在 Linux 中是沒有 download 命令的,但是有幾個 Linux 命令可用於下載文件。在這篇終端技巧中,你將學習兩種在 Linux 中使用命令行下載文件的方法。我在這裡使用的是 Ubuntu,但除了安裝,其餘的命令同樣適用於所有其他 Linux 發行版。
  • AutoRecon 一款多線程網絡偵察工具
    AutoRecon是一種多線程網絡偵察工具,可以執行自動枚舉服務。
  • 並發和並行 | Python中實現多線程 threading 和多進程 multiprocessing
    並發和並行咱們簡單用多線程對應並發,多進程對應並行。多線程並發更強調充分利用性能;多進程並行更強調提升性能上限。我用非常簡單且不那麼嚴謹的比喻來說明。多線程一個 CPU 相當於一個學生。因此,我們用「多線程」來讓學生實現『並發』,充分利用學生能力。giphy.com在實際情況中,多線程、高並發這些詞語更多地出現在服務端程序裡。比如一個網絡連接由一個線程負責,一塊 CPU 可以負責處理多個異步的請求,大大提升了 CPU 利用率。
  • 使用 Axel 命令行下載器/加速器加速下載
    它也可以使用多個鏡像站點下載單個文件,所以,Axel 可以加速下載高達 40%(大約,我個人認為)。它非常輕量級,因為它沒有依賴並且使用非常少的 CPU 和內存。Axel 一步到位地將所有數據直接下載到目標文件(LCTT 譯註:而不是像其它的下載軟體那樣下載成多個文件塊,然後拼接)。注意:不支持在單條命令中下載兩個文件。
  • Python多線程—Thread和Threading
    又到周四,科普Time,今天給大家講講Python多線程中的兩個模塊,Thread和Threading。針對兩個模塊下文中會給出一些實例,給大家加深印象。 說到Python的多線程呢,先介紹一下一定繞不過去的坑,全局解釋器鎖GIL。
  • python基礎之多線程
    什麼是線程