服务器之家:专注于服务器技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Ubuntu - 在Ubuntu系统上使用apt-fast来加快apt-get下载的教程

在Ubuntu系统上使用apt-fast来加快apt-get下载的教程

2019-10-13 16:36开源中文社区 Ubuntu

这篇文章主要介绍了使用apt-fast来加快apt-get下载的教程,适用于使用bash shell的Debian系Linux系统,需要的朋友可以参考下

如果你在Debian或Ubuntu系统上经常感觉到apt-get 或 aptitude包安装速度过慢,那么这里就有几种改善这一情况的方法。你有没有考虑过改变正被使用的默认镜像站点?你有没有排除因特网连接的上游带宽成为瓶颈的可能?

如果不是这些原因,你可以尝试第三个选择:使用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系统上使用apt-fast来加快apt-get下载的教程

在Ubuntu系统上使用apt-fast来加快apt-get下载的教程

在Ubuntu系统上使用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安装一个包

现在你就可以测试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系统上使用apt-fast来加快apt-get下载的教程

 

     如前面所示,apt-fast的并行下载是通过aria2完成的。你可以看到如下图般从多个镜像并行下载。

   

复制代码

代码如下:

$ sudo netstat -nap | grep aria2c


    在Ubuntu系统上使用apt-fast来加快apt-get下载的教程

 

    请注意,apt-fast并没有加速"apt-get update"。并行下载只在"install", "upgrade", "dist-upgrage"和"build-dep"操作中触发。其余的操作,apt-fast就会简单地回到默认的包管理器apt-get或aptitude。
apt-fast有多快?

为了比较apt-fast和apt-get,我尝试在两个相同的Ubuntu实例上使用两种方法安装几个软件包。下面的图表展示了所有软件包安装的时间(单位为秒)。
在Ubuntu系统上使用apt-fast来加快apt-get下载的教程

正如你所见到的,apt-fast确实比apt-get快(e.g. 快3--4秒),特别是安装庞大软件包的时候。

当然,安装性能的提高程度还依赖你上游因特网连通性。以我为例,我有富足的带宽来支持我的上游连接。这也是为什么我看到并行下载带来了成功的提高。

延伸 · 阅读

精彩推荐
  • UbuntuUbuntu Gnome下如何修改应用图标icon?

    Ubuntu Gnome下如何修改应用图标icon?

    最近有些朋友问小编Ubuntu Gnome下如何修改应用图标icon?今天小编要为大家分享的是Ubuntu Gnome下修改应用图标icon的方法;有需要的朋友一起去看看吧...

    服务器之家6412019-06-01
  • UbuntuUbuntu 15.04升级到Ubuntu 15.10的详细教程

    Ubuntu 15.04升级到Ubuntu 15.10的详细教程

    ubuntu15.04怎么升级到ubuntu15.10?又该升级系统了,但是很多人对ubuntu系统很不熟悉,下面我们一起来看看ubuntu15.04升级ubuntu15.10的详细教程,需要的朋友可以...

    服务器之家4562019-07-02
  • UbuntuUbuntu下安装Chrome的方法分享

    Ubuntu下安装Chrome的方法分享

    本文给大家分享的是Ubuntu下安装Chrome的方法,安装的过程中发现还是挺麻烦的,就记录下来推荐给大家,有需要的小伙伴可以参考下。...

    Ubuntu教程网3862021-10-25
  • UbuntuUbuntu安装和卸载CUDA和CUDNN的实现

    Ubuntu安装和卸载CUDA和CUDNN的实现

    这篇文章主要介绍了Ubuntu安装和卸载CUDA和CUDNN的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们...

    夜雨飘零14632020-08-04
  • UbuntuWSL、WSL2与Ubuntu性能大PK

    WSL、WSL2与Ubuntu性能大PK

    科技媒体 Phoronix 对 Windows 10 May 2020 中 WSL 和 WSL 2 的性能进行了测试,参与测试的发行版为 Ubuntu 20.04 on WSL/WSL2 ,以及 Ubuntu 20.04 LTS,均被安装在除 Windows 之...

    开源中国29412020-06-23
  • UbuntuUbuntu17.10怎么添加日历事项? Ubuntu添加行程提醒的教程

    Ubuntu17.10怎么添加日历事项? Ubuntu添加行程提醒的教程

    Ubuntu17.10怎么添加日历事项?Ubuntu17.10系统中有一个日程管理功能,可以在日历中添加行程提醒,下面我们就来看看Ubuntu添加行程提醒的教程,需要的朋友可...

    服务器之家2812019-06-19
  • Ubuntu如何在ubuntu系统中安装pycharm工具并运行

    如何在ubuntu系统中安装pycharm工具并运行

    在Windows系统中安装pycharm,只需要下载安装包,然后根据指令一步一步操作;而在Linux系统中的Ubuntu中安装pycharm,需要下载安装包,还有安装相关的其他软件...

    百度经验12082019-10-21
  • UbuntuUbuntu20.04开启root账户的方法步骤

    Ubuntu20.04开启root账户的方法步骤

    这篇文章主要介绍了Ubuntu20.04开启root账户的方法步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们...

    缀梦13002020-08-01