红联首页 凝聚Linux人的力量
菜鸟过关 | 精华文档 | 同城人(交友) | 我与Linux的故事 | Linux新闻 | Linux视频 | Linux人才 | 软件下载 | 大学校园 | English
 11 12
发新话题
打印

Fedora 8中使用axel加速yum

本主题由 gxf 于 2007-11-12 16:46 提升

Fedora 8中使用axel加速yum

转亚森罗平大侠的贴子
1.自己编辑相关的repo文件fedora.repo和fedora-updates.repo

改为不使用镜像列表,并添加镜像服务器,修改如下:
#fedora.repo文件
复制内容到剪贴板
代码:
[fedora]
name=Fedora $releasever - $basearch
failovermethod=priority
#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
baseurl=  
          http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://mirrors.usc.edu/pub/linux/distributions/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://mirrors.cat.pdx.edu/fedora/linux/releases/$releasever/Everything/$basearch/os/         
          http://ftp.iij.ad.jp/pub/linux/fedora/releases/$releasever/Everything/$basearch/os/
          ftp://ftp.iij.ad.jp/pub/linux/fedora/releases/$releasever/Everything/$basearch/os/
          http://mirror.aarnet.edu.au/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://mirror.internode.on.net/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://gulus.usherbrooke.ca/pub/distro/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://mirror.karneval.cz/pub/linux/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://sunsite.mff.cuni.cz/MIRRORS/fedora.redhat.com/linux/releases/$releasever/Everything/$basearch/os/
          http://ftp-stud.hs-esslingen.de/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://fedora.tu-chemnitz.de/pub/linux/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://mirror.fraunhofer.de/download.fedora.redhat.com/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://ftp.uni-bayreuth.de/linux/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://ftp.funet.fi/pub/mirrors/fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
          ftp://ftp.free.fr/mirrors/fedora.redhat.com/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://limestone.uoregon.edu/ftp/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://fedora.mirror.iweb.ca/releases/$releasever/Everything/$basearch/os/
          ftp://ftp.cse.buffalo.edu/pub/Linux/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://mirror.cc.vt.edu/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://mirrors.tummy.com/pub/fedora.redhat.com/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://mirrors.kernel.org/fedora/releases/$releasever/Everything/$basearch/os/
          http://www.gtlib.gatech.edu/pub/fedora.redhat/linux/releases/$releasever/Everything/$basearch/os/
          http://ftp.linux.ncsu.edu/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://ftp.iij.ad.jp/pub/linux/fedora/releases/$releasever/Everything/$basearch/os/
          ftp://ftp.iij.ad.jp/pub/linux/fedora/releases/$releasever/Everything/$basearch/os/
          http://ftp.yz.yamagata-u.ac.jp/pub/linux/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://ftp.rhnet.is/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
          http://mirror.pacific.net.au/linux/fedora/linux/releases/$releasever/Everything/$basearch/os/
         
         
#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY
#fedora-updates.repo文件
复制内容到剪贴板
代码:
[updates]
name=Fedora $releasever - $basearch - Updates
failovermethod=priority
baseurl=
          http://download.fedora.redhat.com/pub/fedora/linux/updates/$releasever/$basearch/
          http://mirrors.usc.edu/pub/linux/distributions/fedora/linux/updates/$releasever/$basearch/
          http://mirrors.cat.pdx.edu/fedora/linux/updates/$releasever/$basearch/         
          http://ftp.iij.ad.jp/pub/linux/fedora/updates/$releasever/$basearch/
          ftp://ftp.iij.ad.jp/pub/linux/fedora/updates/$releasever/$basearch/
          http://mirror.aarnet.edu.au/pub/fedora/linux/updates/$releasever/$basearch/
          http://mirror.internode.on.net/pub/fedora/linux/updates/$releasever/$basearch/
          http://gulus.usherbrooke.ca/pub/distro/fedora/linux/updates/$releasever/$basearch/
          http://mirror.karneval.cz/pub/linux/fedora/linux/updates/$releasever/$basearch/
          http://sunsite.mff.cuni.cz/MIRRORS/fedora.redhat.com/linux/updates/$releasever/$basearch/
          http://ftp-stud.hs-esslingen.de/pub/fedora/linux/updates/$releasever/$basearch/
          http://fedora.tu-chemnitz.de/pub/linux/fedora/linux/updates/$releasever/$basearch/
          http://mirror.fraunhofer.de/download.fedora.redhat.com/fedora/linux/updates/$releasever/$basearch/
          http://ftp.uni-bayreuth.de/linux/fedora/linux/updates/$releasever/$basearch/
          http://ftp.funet.fi/pub/mirrors/fedora.redhat.com/pub/fedora/linux/updates/$releasever/$basearch/
          ftp://ftp.free.fr/mirrors/fedora.redhat.com/fedora/linux/updates/$releasever/$basearch/
          http://limestone.uoregon.edu/ftp/fedora/linux/updates/$releasever/$basearch/
          http://fedora.mirror.iweb.ca/updates/$releasever/$basearch/
          ftp://ftp.cse.buffalo.edu/pub/Linux/fedora/linux/updates/$releasever/$basearch/
          http://mirror.cc.vt.edu/pub/fedora/linux/updates/$releasever/$basearch/
          http://mirrors.tummy.com/pub/fedora.redhat.com/fedora/linux/updates/$releasever/$basearch/
          http://mirrors.kernel.org/fedora/updates/$releasever/$basearch/
          http://www.gtlib.gatech.edu/pub/fedora.redhat/linux/updates/$releasever/$basearch/
          http://ftp.linux.ncsu.edu/pub/fedora/linux/updates/$releasever/$basearch/
          http://ftp.iij.ad.jp/pub/linux/fedora/updates/$releasever/$basearch/
          ftp://ftp.iij.ad.jp/pub/linux/fedora/updates/$releasever/$basearch/
          http://ftp.yz.yamagata-u.ac.jp/pub/linux/fedora/linux/updates/$releasever/$basearch/
          http://ftp.rhnet.is/pub/fedora/linux/updates/$releasever/$basearch/
          http://mirror.pacific.net.au/linux/fedora/linux/updates/$releasever/$basearch/
         
#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f$releasever&arch=$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
下载我打包好的repo文件yum.repos.tar.gz[谁下载了此文件?],将原来的文件备份,然后覆盖

注意:这里的服务器可以自己定义,你可以只选择对自己来说最快的几个服务器即可

2.a.下载axel源码包并进行编译
到下面站点下载最新的axel源码包,http://wilmer.gaast.net/main.php/axel.html

.进入下载目录:
$tar zxvf 文件名
$cd 解压出来的目录
$./configure --i18n=1
$make
$make install

b.下载站点上有axel的rpm包提供,我没有试,有兴趣的帮忙试一下

3.我修改了服务器的地址,直接定位到rpm包所在的目录,因此无须进行判断,直接下载即可,如果使用的是镜像列表,则仍然需要进行i386和os的判断,具体请参见wq1977兄弟的帖子--关于yum太慢了的解决方案
我修改过的axelget,去掉了os,axelget.py文件代码:
复制内容到剪贴板
代码:
from yum.plugins import PluginYumExit, TYPE_CORE, TYPE_INTERACTIVE
from urlparse import urljoin
import os

requires_api_version = '2.3'
plugin_type = (TYPE_CORE, TYPE_INTERACTIVE)

enablesize=300000
trymirrornum=-1
maxconn=10

def init_hook(conduit):
    global enablesize,trymirrornum,maxconn
    enablesize = conduit.confInt('main','enablesize',default=30000)
    trymirrornum = conduit.confInt('main','trymirrornum',default=-1)
    maxconn = conduit.confInt('main','maxconn',default=10)

def predownload_hook(conduit):
    global enablesize
    preffermirror=""
    for po in (conduit.getDownloadPackages()):        
        if hasattr(po, 'pkgtype') and po.pkgtype == 'local':
            continue
        totsize = long(po.size)
        ret = False
        if totsize <= enablesize:
            conduit.info(2, "Package %s download size %d less than %d,Skip plugin!"  % (po.repo.id,totsize,enablesize))
            continue
        else:
            conduit.info(2, "Ok,we will try to use axel to download this big file:%d" % totsize)
        local = po.localPkg()
        if os.path.exists(local):
            if not os.path.exists(local+".st"):
                fstate=os.stat(local)
                if totsize == fstate.st_size:
                    conduit.info(2,"Target already exists,skip to next file!")
                    continue
        localall = "%s %s" % (local,local+".st")
        rmcmd = "rm -f %s" % (localall)
        curmirroridx = 0
        conduit.info(2,"Before we start,clean all the key files")
        os.system(rmcmd)
        connnum = totsize / enablesize
        if connnum > maxconn:
            connnum = maxconn
        mirrors=[]
        mirrors[:0]=po.repo.urls
        if preffermirror != "":
            mirrors[:0] = [preffermirror]
        for url in mirrors:
            curmirroridx += 1
            if (curmirroridx > trymirrornum) and (trymirrornum != -1):
                conduit.info(2, "Package %s has tried %d mirrors,Skip plugin!" % (po.repo.id,trymirrornum))
                break
            remoteurl = urljoin(url, "%s" % po.remote_path)
            syscmd = "axel -a -n %s %s -o %s" % (connnum,remoteurl,local)
            conduit.info(2, "Execute axel cmd:\n%s"  % syscmd)
            os.system(syscmd)
            if os.path.exists(local+".st"):
                conduit.info(2,"axel exit by exception,let's try another mirror")
                continue
            else:
                ret = True
                preffermirror=url
                break
        if not ret:
            conduit.info (2,"try to run rm cmd:%s"  % rmcmd)
            os.system(rmcmd)
axelget.conf文件代码:
复制内容到剪贴板
代码:
[main]
enabled=1
enablesize=10000
trymirrornum=3
新建这两个文件,将文件axelget.conf放入/etc/yum/pluginconf.d/目录,将axelget.py放入/usr/lib/yum-plugins/即可

然后:
sudo yum clean all
sudo yum update

4.注意事项:
1.如果出现错误找不到axel命令,编辑~/.bash_profile ,将PATH改为如下所示:
PATH=$PATH:$HOME/bin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin

2.可在http://mirrors.fedoraproject.org/publiclist/Fedora/$releasever/$basearch/查询可用的服务器,可能是因为Fedora 8 刚刚发布,所以有部分服务器还没有开放updates,如果提示没有这个目录,建议换个服务器或者是等待一段时间再试

3.baseurl的第一个服务器是绝对可以用的,是稳妥的设置,但速度上比较一般,50-100KB/s的样子可以根据自己实际情况更改为更快的服务器。

原文章出处
本帖最近评分记录
  • gxf 威望 +5 正在失望于yum的绝对可以一试 2007-11-11 01:59

TOP

好东西~
MM的,这个yum的确让人很失望~
试试先。。。
GF要我戒咖啡,却又给我买咖啡奶球!
Blog.im321.com

TOP

兄弟,试了行不行啊?
我都没敢用YUM装MP

TOP

做好备份试试吧
"Genius is one percent inspiration and 99 percent perspiration" --- Thomas Alva Edison.

TOP

试过的有成功的没 ? 偶没觉得速度提高有多大   
魚骨頭oοO

TOP

企盼Fedora 8中被跳票的yum加速,Redhat 为什么要吊我们胃口呢。

TOP

有一段时间心情不太好,就用Linux来打发时间疗养心情,就把单位的PC偷偷装了个fc4,用了一段时间开始装fc5,后来fc6……最后fc8,fc9,每次装完系统后总是受不了yum速度,还不得不用它,于是千万种方法设置,想了N个提速的办法,装了M个提速的插件,都不太成功,下载速度是十几K,二十来K。
   自从看了 million贴后,用axel多线下载yum源上的包,yum速度居然能达到1M左右(单位用的CNC光纤),家中用的CNC的ADSL也达到400K左右,感觉象在用windows中的讯雷在下载,从此以后再看yum升级的时速度,让人有点惊喜,几十MB包看它三闪二闪就没了,感觉还没看过瘾呢。嘻,Linux真可以,fedora真可爱,yum真好,axel真好……
     有了yum加axel这个好工具以后,Fedora被收拾的比windows还要好,fedora的界面比windows华丽,速度更比windows流畅,windowse有的它都有,甚到MS法宝的WORD与EXCEL,windows没有它还有,它咋那么可爱呢,因为它是Linux!windows是微软的,Linux是大伙的,是你的,是我的,
呵!说跑题了,为了贺祝下这种愉快的心情,为了祝贺 million君这贴救世的贴子,于是写了一个安装脚本。
您下载了下面gz包附件以后先解压
tar -zxvf yumaxel.tar.gz
cd yumaxel
./yumaxel.sh
如果安装成功yum clean all;yum update试一下,我的运行环境是fedora 8,yum update下载了1.5G左右大概一小左右。

本安装脚本在安装axel插件前先将/etc/yum.repos.d/配置文件做了个备份,生成了gz包在/etc/yum.repos.d中,先添加了livna与freshrpms两个源。
如果安装失败请参看解压包中的readme.txt进行手工安装。
如您已经装了fastestmirror插件而不能正常运行yum就把fastestmirror卸掉,或者禁止运行。我的yum启动axel一个插件。
愿您加速成功,心情愉快,更加热爱Linux!
附件: 您所在的用户组无法下载或查看附件

TOP

fedora的源和ubuntu的源相比,速度真是差N多啊,但我还是喜欢用fedora,ubuntu一点不喜欢,这么多人使用fedora为什么国内源这么少啊,郁闷

TOP

axel也不怎么帮忙啊,不用插件的

TOP

巨慢!!!还没有yum快呢。才零点几K,yum还十来K呢

TOP

 11 12
发新话题