溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

如何在Ubuntu系統(tǒng)上使用apt-fast來加快apt-get下載

發(fā)布時間:2021-09-27 10:30:05 來源:億速云 閱讀:127 作者:iii 欄目:系統(tǒng)運維

這篇文章主要講解了“如何在Ubuntu系統(tǒng)上使用apt-fast來加快apt-get下載”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“如何在Ubuntu系統(tǒng)上使用apt-fast來加快apt-get下載”吧!

如果你在Debian或Ubuntu系統(tǒng)上經(jīng)常感覺到apt-get 或 aptitude包安裝速度過慢,那么這里就有幾種改善這一情況的方法。你有沒有考慮過改變正被使用的默認鏡像站點?你有沒有排除因特網(wǎng)連接的上游帶寬成為瓶頸的可能?

如果不是這些原因,你可以嘗試第三個選擇:使用apt-fast工具。apt-fast實際上是一個圍繞apt-get和aptitude所寫的shell腳本容器,它能加速包的下載速度。apt-fast本質上采用aria2下載工具,這款工具能夠以“塊”的方式從多個鏡像并行下載一個文件(就像BitTorrent下載)。

在Debian或Ubuntu上安裝apt-fast

下面是在基于Debian的Linux上安裝apt-fast的步驟
Debian   

代碼如下:

$ sudo apt-get install aria2
   $ wget https://github.com/ilikenwf/apt-fast/archive/master.zip
   $ unzip master.zip
   $ cd apt-fast-master
   $ sudo cp apt-fast /usr/bin
   $ sudo cp apt-fast.conf /etc
   $ sudo cp ./man/apt-fast.8 /usr/share/man/man8
   $ sudo gzip /usr/share/man/man8/apt-fast.8
   $ sudo cp ./man/apt-fast.conf.5 /usr/share/man/man5
   $ sudo gzip /usr/share/man/man5/apt-fast.conf.5

Ubuntu 14.04 以及更高版本   

代碼如下:

$ sudo add-apt-repository ppa:saiarcot895/myppa
   $ sudo apt-get update
   $ sudo apt-get install apt-fast

Ubuntu 11.04 到 Ubuntu 13.10   

代碼如下:

$ sudo add-apt-repository ppa:apt-fast/stable
   $ sudo apt-get update
   $ sudo apt-get install apt-fast

在安裝期間,你需要選擇一個默認的軟件包管理器 (e.g., apt-get. aptitude ),還需要設置其余選項。但是你可以隨時通過編輯配置文件 /etc/apt-fast/conf 來更改設置。
如何在Ubuntu系統(tǒng)上使用apt-fast來加快apt-get下載

如何在Ubuntu系統(tǒng)上使用apt-fast來加快apt-get下載

如何在Ubuntu系統(tǒng)上使用apt-fast來加快apt-get下載

配置 apt-get

安裝完成后,你需要在/etc/apt-fast.conf里配置apt-fast使用的一系列鏡像。

你可以在下面的URL中找到一系列Debian/Ubuntu鏡像。

    Debian: http://www.debian.org/mirror/list
    Ubuntu: https://launchpad.net/ubuntu/+archivemirrors

選擇完那些地理上靠近你的鏡像后,你需按照下面的格式將選擇的鏡像加入到/etc/apt-fast.conf。   

代碼如下:

$ sudo vi /etc/apt-fast.conf

Debian:   

代碼如下:

MIRRORS=('http://ftp.us.debian.org/debian/,http://carroll.aset.psu.edu/pub/linux/distributions/debian/,http://debian.gtisc.gatech.edu/debian/,http://debian.lcs.mit.edu/debian/,http://mirror.cc.columbia.edu/debian/')

Ubuntu/Mint:   

代碼如下:

MIRRORS=('http://us.archive.ubuntu.com/ubuntu,http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/,http://mirror.cc.vt.edu/pub2/ubuntu/,http://mirror.umd.edu/ubuntu/,http://mirrors.mit.edu/ubuntu/')

如上面所示,對于一個特定檔案的個別鏡像,需要用逗號分割開來。你需要在/etc/apt/sources.list的MIRRORS字符串中包含默認的鏡像指定站點。
使用apt-fast安裝一個包

現(xiàn)在你就可以測試apt-fast的強大了。下面是使用apt-fast的示例:   

代碼如下:

apt-fast [apt-get options and arguments]
   apt-fast [aptitude options and arguments]
   apt-fast { { install | upgrade | dist-upgrade | build-dep | download  | source  } [ -y | --yes | --assume-yes | --assume-no ]   ... | clean }

使用apt-fast安裝包:    

代碼如下:

$ sudo apt-fast install texlive-full

在當前目錄下載軟件包,但不安裝:    

代碼如下:

$ sudo apt-fast download texlive-full


     如何在Ubuntu系統(tǒng)上使用apt-fast來加快apt-get下載

     如前面所示,apt-fast的并行下載是通過aria2完成的。你可以看到如下圖般從多個鏡像并行下載。  

代碼如下:

$ sudo netstat -nap | grep aria2c


    如何在Ubuntu系統(tǒng)上使用apt-fast來加快apt-get下載

    請注意,apt-fast并沒有加速"apt-get update"。并行下載只在"install", "upgrade", "dist-upgrage"和"build-dep"操作中觸發(fā)。其余的操作,apt-fast就會簡單地回到默認的包管理器apt-get或aptitude。
apt-fast有多快?

為了比較apt-fast和apt-get,我嘗試在兩個相同的Ubuntu實例上使用兩種方法安裝幾個軟件包。下面的圖表展示了所有軟件包安裝的時間(單位為秒)。
如何在Ubuntu系統(tǒng)上使用apt-fast來加快apt-get下載

正如你所見到的,apt-fast確實比apt-get快(e.g. 快3--4秒),特別是安裝龐大軟件包的時候。

當然,安裝性能的提高程度還依賴你上游因特網(wǎng)連通性。以我為例,我有富足的帶寬來支持我的上游連接。這也是為什么我看到并行下載帶來了成功的提高。

感謝各位的閱讀,以上就是“如何在Ubuntu系統(tǒng)上使用apt-fast來加快apt-get下載”的內容了,經(jīng)過本文的學習后,相信大家對如何在Ubuntu系統(tǒng)上使用apt-fast來加快apt-get下載這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。

AI