LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: wq1977

关于yum太慢了的解决方案

[复制链接]
发表于 2007-6-16 07:30:04 | 显示全部楼层

yum update问题

我安装了yum的axe插件,结果在升级时,出现了这样的问题
axel -a http://ftp.yz.yamagata-u.ac.jp/p ... .57-12.fc7.i386.rpm -o //var/cache/yum/fedora/packages/libsidplay-1.36.57-12.fc7.i386.rpm
Initializing download: http://ftp.yz.yamagata-u.ac.jp/p ... .57-12.fc7.i386.rpm
HTTP/1.1 404 Not Found
Execute axel cmd:
axel -a http://limestone.uoregon.edu/ftp ... .57-12.fc7.i386.rpm -o //var/cache/yum/fedora/packages/libsidplay-1.36.57-12.fc7.i386.rpm
Initializing download: http://limestone.uoregon.edu/ftp ... .57-12.fc7.i386.rpm
HTTP/1.1 404 Not Found
Execute axel cmd:
axel -a ftp://ftp.applios.net/pub/fedora ... .57-12.fc7.i386.rpm -o //var/cache/yum/fedora/packages/libsidplay-1.36.57-12.fc7.i386.rpm
Initializing download: ftp://ftp.applios.net/pub/fedora ... .57-12.fc7.i386.rpm

Execute axel cmd:
axel -a http://mirror.stanford.edu/fedor ... .57-12.fc7.i386.rpm -o //var/cache/yum/fedora/packages/libsidplay-1.36.57-12.fc7.i386.rpm
Initializing download: http://mirror.stanford.edu/fedor ... .57-12.fc7.i386.rpm
HTTP/1.1 404 Not Found
Execute axel cmd:
axel -a http://ftp.usf.edu/pub/fedora/li ... .57-12.fc7.i386.rpm -o //var/cache/yum/fedora/packages/libsidplay-1.36.57-12.fc7.i386.rpm
Initializing download: http://ftp.usf.edu/pub/fedora/li ... .57-12.fc7.i386.rpm
HTTP/1.1 404 Not Found
Package fedora has tried 6 mirrors,Skip plugin!
try to run rm cmd:rm -f //var/cache/yum/fedora/packages/libsidplay-1.36.57-12.fc7.i386.rpm //var/cache/yum/fedora/packages/libsidplay-1.36.57-12.fc7.i386.rpm.st
就是找不着文件,打开相应网址一看呢,地址有问题,也就是说,是yum的配置文件有问题(yum-updates.repo),我想如果修改一下,应该就可以用了,不过不知如何修改。哪位高手帮忙说明一下如何修改,或者解释一下,repo文件里的参数是何意思?如下:
[updates]
name=Fedora $releasever - $basearch - Updates
#baseurl=http://download.fedora.redhat.com/pub/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
着重带$符的谢谢!!!
回复 支持 反对

使用道具 举报

发表于 2007-6-16 22:03:51 | 显示全部楼层
楼上的问题我也遇到,不知道是什么原因。
对于我的机器:
$releasever = 7 (指fedora7)
$basearch = i386 (指架构)

应该不是repo的问题,删除了这个plugin和axel后,yum工作正常。

Fedora7的软件仓库的目录结构与原先的Fc6不同,可能需要楼主的代码作调整吧。希望作者和哪位高手能修改一下,毕竟这个插件的提速效果十分明显,不能用很可惜!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-6-17 11:27:36 | 显示全部楼层
谢谢这么多热心朋友的捧场。有些朋友以邮件或者悄悄话的形式询问了一些问题,在此统一回答一下:

1: 关于Fedora 7的问题。 由于Fedora 7 暂时还不能支持我的ATI的显卡,短期内没有升级到Fedora 7的打算,所以相关问题暂时无法回答。

2: 关于遇到Not Found的问题。 可能是在某些情况下拼凑remote url的方法不对,实际地址中少了 i386这个目录,增加上就可以了。

3:对于为什么要在开始下载前删除原先的文件或者在下载彻底失败后删除下载了一半的文件,主要是因为,下载失败以后将会使用yum自己的方式下载,如果目标文件已经存在,会导致yum下载到不可用的文件。

我对这个插件进行了一些改进,主要增加的功能如下:

第一: 增加了对目标文件的判断,如果目标文件已经存在并且大小和要求的大小相同,则认为文件已经存在,不再重复下载。  

第二: 根据目标文件的大小自适应axel连接的数目,目前采用文件大小除以最小文件大小的方式来计算连接数。因为这个连接数并不是越多越好,对于小文件,很多的连接数不但导致下载速度降低,而且也容易出现下载错误。

第三: 下载下一个文件的时候将优先使用前一个下载的mirror。

第四:修正了原有的一些缺陷。比如如果第一个文件是小文件则后面的都不用axel下载,默认仅尝试前三个mirror等。

下面给出完整代码,有任何意见建议欢迎跟帖。

[PHP]
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, "ackage %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, "ackage %s has tried %d mirrors,Skip plugin!" % (po.repo.id,trymirrornum))
                                break
                        remoteurl = urljoin(url, "i386/%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)
[/PHP]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

发表于 2007-6-17 12:46:30 | 显示全部楼层
原来代码中地址中缺少的“os/”而非楼主所说的“i386”,故将axelget.py中
remoteurl = urljoin(url, "i386/%s" % po.remote_path)

改为:
remoteurl = urljoin(url, "os/%s" % po.remote_path)

后,一切恢复正常!!下载速度飞快!!!!!!!

Downloading Packages:
Ok,we will try to use axel to download this big file:12229577
Before we start,clean all the key files
Execute axel cmd:
axel -a -n 10 http://distro.ibiblio.org/pub/li ... .0.4-2.fc7.i386.rpm -o //var/cache/yum/fedora/packages/azureus-2.5.0.4-2.fc7.i386.rpm
Initializing download: http://distro.ibiblio.org/pub/li ... .0.4-2.fc7.i386.rpm
File size: 12229577 bytes
Opening output file //var/cache/yum/fedora/packages/azureus-2.5.0.4-2.fc7.i386.rpm
Starting download

Connection 1 finished                                                          ]
Connection 9 finished                                                          ]
Connection 8 finished                                                          ]
Connection 3 finished                                                          ]
Connection 5 finished                                                          ]
Connection 6 finished                                                          ]
Connection 7 finished                                                          ]
Connection 0 finished                                                          ]
Connection 2 finished                                                          ]
[100%] [..................................................] [  98.0KB/s] [00:00]

Downloaded 11.7 megabytes in 2:01 seconds. (98.03 KB/s)
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: azureus                      ######################### [1/1]

Installed: azureus.i386 0:2.5.0.4-2.fc7
Complete!


我注意到新的功能在起作用,我这次下载用了10个连接。

谢谢楼主的贡献!
回复 支持 反对

使用道具 举报

发表于 2007-6-17 13:19:01 | 显示全部楼层
支持,昨晚F7装了使用了,速度飞快!!!
感谢wq1997兄弟写出这么实用的插件!!!
回复 支持 反对

使用道具 举报

发表于 2007-6-17 17:26:07 | 显示全部楼层
刚才试图进行一个系统提示的18个包的升级时,出现原来的错误。

改回“i386/”后正常,这是由于fedora库和update库不同的结构造成的。

希望楼主给考虑一下,如何可以兼顾两边。

给个比较:

1、fedora库:
http://distro.ibiblio.org/pub/li ... .0.4-2.fc7.i386.rpm
2、update库:
http://gulus.usherbrooke.ca/pub/ ... 10.2-3.fc7.i386.rpm
回复 支持 反对

使用道具 举报

发表于 2007-6-26 17:53:53 | 显示全部楼层
Post by firefoxmmx
如果喜欢用图形yum的朋友,常常可以看到,有些yum插件无法加载~~~~

比如楼主写的axelget.py~~

你只需要一个小的改动,就可以正常加载了~~~~
先到/usr/lib/python2.4/site-packages/下,
如果你的用的yumex 你只需要改动yumex/yumexBase.py,找到下面部分加入红色部分

  1.   # Only use CORE Plugins
  2.             if not self.yumexconf.noplugins:
  3.                 self.progresslog( _( "Setup Yum : Plugins" ) )
  4.                 self.doConfigSetup( plugin_types=( yum.plugins.TYPE_CORE, [color="Red"]yum.plugins.TYPE_INTERACTIVE[/color] ), debuglevel=self.yumexconf.yumdebuglevel )
  5.             else:
  6.                 self.progresslog( _( "Setup Yum : Plugins are disabled" ) )
复制代码


如果是用pirut的朋友可以在,pirut/__init__.py里找到
相同的部分,加入红色部分即可~~

然后启动yumex或者pirut,看是不是多了你的插件了~~


fc7 根本就没有那个目录,怎么改
回复 支持 反对

使用道具 举报

发表于 2007-9-1 10:33:04 | 显示全部楼层
Post by lgyaalgy
axelget.conf和axelget.py两个文件下不了,似乎网址错误,不知哪位能帮忙上传一下,谢谢!



我现在也是下载不了这两个文件:mad:
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-9-1 13:03:18 | 显示全部楼层
我现在已经升级到Fedora7 并且对axelget这个plugin作了一点改进,以后这个插件将会和我在 一个显示股票信息的gdesklet中介绍的代码一样,使用同样的svn来维护,想下载axelget的朋友,以后可以通过如下的方法下载:

svn co http://cnfreesoft.googlecode.com/svn/trunk/axelget/  <your_path>/axelget
su
cd /etc/yum/pluginconf.d/
ln -s <your_path>/axelget/axelget.conf .
cd /usr/lib/yum-plugins/
ln -s <your_path>/axelget/axelget.py .

这样就可以了,以后有了新的改动,只需要去<your_path>/axelget目录中进行 svn up 就可以了。

axel 下载: http://wilmer.gaast.net/main.php/axel.html

Good Luck.
回复 支持 反对

使用道具 举报

发表于 2007-9-13 14:13:52 | 显示全部楼层
好用!
已经版本60了?更新那么快?

鉴于yum速度慢这个问题的普遍性,我强烈建议此帖置顶!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表