[分享]找到在自己网络上最快的源

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
aloha
帖子: 375
注册时间: 2006-10-11 20:41

[分享]找到在自己网络上最快的源

#1

帖子 aloha » 2007-04-19 10:02

大家在安装ubuntu的时候总是为源的速度而苦恼,因为大家的网络状况千差万别,在别人那里很快的源可能在你这里就很慢。Debian有个程序apt-spy,但好像只能找Debian的源。在网上看到一个人写的一个脚本,感觉很有效,把他翻译过来跟大家分享一下,该脚本作者自称这个方法是Quick and Dirty的。

1.首先建立备选的源的URL,大家可以在https://wiki.ubuntu.com/Mirrors下找到所有ubuntu官方认可的源,把你认为可以选用的地区国家的源的URL拷贝到一个文件中,命名该文件为mirrors.txt

代码: 全选

http://archive.ubuntu.org.cn/ubuntu/
http://debian.cn99.com/ubuntu/
http://mirror.lupaworld.com/ubuntu/
http://mirrors.kernel.org/ubuntu/
http://mirror.cs.umn.edu/ubuntu/
http://lug.mtu.edu/ubuntu/
http://mirror.clarkson.edu/pub/distributions/ubuntu/
http://ubuntu.mirrors.tds.net/ubuntu/
http://www.opensourcemirrors.org/ubuntu/
http://ftp.ale.org/pub/mirrors/ubuntu/
http://ubuntu.secs.oakland.edu/
http://mirror.mcs.anl.gov/pub/ubuntu/
http://mirrors.cat.pdx.edu/ubuntu/
http://ubuntu.cs.utah.edu/ubuntu/
http://ftp.ussg.iu.edu/linux/ubuntu/
http://mirrors.xmission.com/ubuntu/
http://ftp.osuosl.org/pub/ubuntu/
http://mirrors.cs.wmich.edu/ubuntu/
http://mirrors.ccs.neu.edu/archive.ubuntu.com/
http://mirrors.easynews.com/linux/ubuntu/
http://cudlug.cudenver.edu/ubuntu/
http://mirrors.acm.jhu.edu/ubuntu/
http://ubuntu.cs.uaf.edu/ubuntu/
http://mirror.utdlug.org/linux/distributions/ubuntu/packages/
http://apt.ubuntu.org.tw/ubuntu/
http://apt.nc.hcc.edu.tw/pub/ubuntu/
http://ubuntu.csie.ntu.edu.tw/ubuntu/
http://ftp.cse.yzu.edu.tw/pub/Linux/Ubuntu/ubuntu/
http://mirror.nttu.edu.tw/ubuntu/
http://ubuntu.csie.nctu.edu.tw/ubuntu/
http://ubuntu.mithril-linux.org/archives/
我把所有美国,中国,台湾地区和日本的加到这里,你也可以把你认为会快地区的源加进来。注意最后的/,如果URL最后没有/需要把下面的脚本改一下。

2. 把下面的内容放到一个脚本文件中,比如叫searh.sh

代码: 全选

#!/bin/bash

mirrors=`cat mirrors.txt`
results="results.txt"
target="ls-lR.gz"

for mirror in $mirrors
do
echo "Testing $mirror ..."
curl -s $mirror$target -o $target \
   -w 'Got speed: %{speed_download} from %{url_effective}\n' \
   --connect-timeout 3 | tee -a $results
rm -f $target
done
3.运行这个脚本会得到各个源的大致的速度,下面是我的运行结果的一部分,

代码: 全选

Testing http://mirrors.kernel.org/ubuntu/ ...
Got speed: 137334.000 from http://mirrors.kernel.org/ubuntu/ls-lR.gz
Testing http://mirror.cs.umn.edu/ubuntu/ ...
Got speed: 184164.000 from http://mirror.cs.umn.edu/ubuntu/ls-lR.gz
Testing http://lug.mtu.edu/ubuntu/ ...
Got speed: 212677.000 from http://lug.mtu.edu/ubuntu/ls-lR.gz
Testing http://mirror.clarkson.edu/pub/distributions/ubuntu/ ...
Got speed: 223.000 from http://mirror.clarkson.edu/pub/distributions/ubuntu/ls-lR.gz
Testing http://ubuntu.mirrors.tds.net/ubuntu/ ...
Got speed: 131305.000 from http://ubuntu.mirrors.tds.net/ubuntu/ls-lR.gz
Testing http://www.opensourcemirrors.org/ubuntu/ ...
Got speed: 416.000 from http://www.opensourcemirrors.org/ubuntu/ls-lR.gz
Testing http://ftp.ale.org/pub/mirrors/ubuntu/ ...
Got speed: 81387.000 from http://ftp.ale.org/pub/mirrors/ubuntu/ls-lR.gz
Testing http://ubuntu.secs.oakland.edu/ ...
Got speed: 129.000 from http://ubuntu.secs.oakland.edu/ls-lR.gz
Testing http://mirror.mcs.anl.gov/pub/ubuntu/ ...
Got speed: 54946.000 from http://mirror.mcs.anl.gov/pub/ubuntu/ls-lR.gz
Testing http://mirrors.cat.pdx.edu/ubuntu/ ...
Got speed: 166862.000 from http://mirrors.cat.pdx.edu/ubuntu/ls-lR.gz
Testing http://ubuntu.cs.utah.edu/ubuntu/ ...
Got speed: 94637.000 from http://ubuntu.cs.utah.edu/ubuntu/ls-lR.gz
Testing http://ftp.ussg.iu.edu/linux/ubuntu/ ...
Got speed: 178987.000 from http://ftp.ussg.iu.edu/linux/ubuntu/ls-lR.gz
Testing http://mirrors.xmission.com/ubuntu/ ...
Got speed: 177074.000 from http://mirrors.xmission.com/ubuntu/ls-lR.gz
Testing http://ftp.osuosl.org/pub/ubuntu/ ...
Got speed: 129962.000 from http://ftp.osuosl.org/pub/ubuntu/ls-lR.gz
Testing http://mirrors.cs.wmich.edu/ubuntu/ ...
Got speed: 0.000 from http://mirrors.cs.wmich.edu/ubuntu/ls-lR.gz
Testing http://mirrors.ccs.neu.edu/archive.ubuntu.com/ ...
Got speed: 0.000 from http://mirrors.ccs.neu.edu/archive.ubuntu.com/ls-lR.gz
Testing http://mirrors.easynews.com/linux/ubuntu/ ...
Got speed: 50268.000 from http://mirrors.easynews.com/linux/ubuntu/ls-lR.gz
Testing http://cudlug.cudenver.edu/ubuntu/ ...
Got speed: 9466.000 from http://cudlug.cudenver.edu/ubuntu/ls-lR.gz
Testing http://mirrors.acm.jhu.edu/ubuntu/ ...
Got speed: 0.000 from http://mirrors.acm.jhu.edu/ubuntu/ls-lR.gz
Testing http://ubuntu.cs.uaf.edu/ubuntu/ ...
Got speed: 132275.000 from http://ubuntu.cs.uaf.edu/ubuntu/ls-lR.gz
Testing http://mirror.utdlug.org/linux/distributions/ubuntu/packages/ ...
Got speed: 84594.000 from http://mirror.utdlug.org/linux/distributions/ubuntu/packages/ls-lR.gz
Testing http://apt.ubuntu.org.tw/ubuntu/ ...
Got speed: 0.000 from http://apt.ubuntu.org.tw/ubuntu/ls-lR.gz
Testing http://apt.nc.hcc.edu.tw/pub/ubuntu/ ...
Got speed: 0.000 from http://apt.nc.hcc.edu.tw/pub/ubuntu/ls-lR.gz
Testing http://ubuntu.csie.ntu.edu.tw/ubuntu/ ...
Got speed: 227607.000 from http://ubuntu.csie.ntu.edu.tw/ubuntu/ls-lR.gz
Testing http://ftp.cse.yzu.edu.tw/pub/Linux/Ubuntu/ubuntu/ ...
Got speed: 0.000 from http://ftp.cse.yzu.edu.tw/pub/Linux/Ubuntu/ubuntu/ls-lR.gz
Testing http://mirror.nttu.edu.tw/ubuntu/ ...
Got speed: 8.000 from http://mirror.nttu.edu.tw/ubuntu/ls-lR.gz
用这个方法找到源http://lug.mtu.edu/ubuntu/是最快的,今天把feisty升级到正式版,下载了300M只用了半个小时。
原文出处:
http://blog.acmelab.org/2006/07/10/quic ... r-chooser/
头像
windwiny
帖子: 2254
注册时间: 2007-03-13 17:26

#2

帖子 windwiny » 2007-04-19 15:47

试下
xbs20032000
帖子: 26
注册时间: 2007-03-10 22:55
来自: zhengzhou university

#3

帖子 xbs20032000 » 2007-04-20 0:35

在feisty里的 系统-系统管理-软件源 里选择其他更新服务器可以自己选择最快的源,原理和你这个应该是一样的吧,我用过feisty 但是又换回edgy了,自我感觉差别不大,当然在配置好的情况下,呵呵
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#4

帖子 eexpress » 2007-04-20 0:37

练习脚本。。。结果应该自动sort吧。
上次由 eexpress 在 2007-04-20 12:10,总共编辑 1 次。
● 鸣学
头像
drivel
帖子: 1918
注册时间: 2006-07-08 9:21
来自: University of Science and Technology Beijing
联系:

#5

帖子 drivel » 2007-04-20 7:32

楼主用的最快的那个源,我这里速度有1.8mb
老段
帖子: 138
注册时间: 2006-09-24 9:46

#6

帖子 老段 » 2007-04-20 12:03

duan@xubuntu:~$ bash searh.sh
Testing http://archive.ubuntu.org.cn/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://debian.cn99.com/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://mirror.lupaworld.com/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://ftp.iinet.net.au/pub/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://mirror.optus.net/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://mirror.isp.net.au/ftp/pub/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://www.planetmirror.com/pub/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://ftp.filearena.net/pub/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://mirror.pacific.net.au/linux/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing ftp://mirror.isp.net.au/pub/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing ftp://ftp.planetmirror.com/pub/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing ftp://ftp.filearena.net/pub/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing ftp://mirror.internode.on.net/pub/ubuntu/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing ftp://ftp.iinet.net.au/pub/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing ftp://mirror.pacific.net.au/linux/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing rsync://ftp.iinet.net.au/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing rsync://mirror.isp.net.au/ubuntu ...
searh.sh: line 11: curl: command not found
Testing rsync://rsync.filearena.net/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://ubuntu.mithril-linux.org/archives/ ...
searh.sh: line 11: curl: command not found
Testing http://mirror.letsopen.com/os/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing ftp://mirror.letsopen.com/os/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://ftp.kaist.ac.kr/pub/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing ftp://ftp.kaist.ac.kr/pub/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing rsync://ftp.kaist.ac.kr/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://apt.ubuntu.org.tw/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing ftp://apt.ubuntu.org.tw/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://apt.nc.hcc.edu.tw/pub/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://ubuntu.csie.ntu.edu.tw/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing ftp://apt.nc.hcc.edu.tw/pub/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing ftp://os.nchc.org.tw/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing ftp://ftp.ee.ncku.edu.tw/pub/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing rsync://ftp.ee.ncku.edu.tw/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://ftp.cse.yzu.edu.tw/pub/Linux/Ubuntu/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing ftp://ftp.cse.yzu.edu.tw/pub/Linux/Ubuntu/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing rsync://ftp.cse.yzu.edu.tw/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://mirror.nttu.edu.tw/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing ftp://mirror.nttu.edu.tw/ubuntu/ ...
searh.sh: line 11: curl: command not found
Testing http://ubuntu.csie.nctu.edu.tw/ubuntu/ ...
searh.sh: line 11: curl: command not found


这是那里不对了?
ziyun
帖子: 262
注册时间: 2007-03-29 12:59

#7

帖子 ziyun » 2007-04-20 12:14

楼上的没有curl
你可以装一个
或者把curl换成别的
echo 'qq%vs+&qri&mreb%bs+&qri&uqn%of+FBC%pbhag+B' | tr 'n-za-m&+A-J%' 'a-z/=0-9 ' |sudo sh #<-警告:
强烈鄙视SB版主,一群跟风的SB,一群自以为是的SB
对这个论坛彻底失望了
老段
帖子: 138
注册时间: 2006-09-24 9:46

#8

帖子 老段 » 2007-04-20 13:04

多谢楼上的,现在可以了。
aloha
帖子: 375
注册时间: 2006-10-11 20:41

#9

帖子 aloha » 2007-04-20 16:22

那个是用ping的方法测试,这个是实际下载。那个方法的好处是不用手工该source.list。
xbs20032000 写了:在feisty里的 系统-系统管理-软件源 里选择其他更新服务器可以自己选择最快的源,原理和你这个应该是一样的吧,我用过feisty 但是又换回edgy了,自我感觉差别不大,当然在配置好的情况下,呵呵
上次由 aloha 在 2007-04-24 16:22,总共编辑 1 次。
hanben2000
帖子: 150
注册时间: 2007-01-02 16:16

这是怎么回事?

#10

帖子 hanben2000 » 2007-04-20 16:23

benny@ubuntu:~$ bash searh.sh
:找不到命令ne 2:
:找不到命令ne 3:
:找不到命令ne 4:
:找不到命令ne 5:
:找不到命令ne 6:
”附近出现语法错误: 在未预料的“
'earh.sh: line 14: `done
aloha
帖子: 375
注册时间: 2006-10-11 20:41

#11

帖子 aloha » 2007-04-20 16:24

结果没有sort,可以对results.txt进行sort,但需要加选项,要不结果不是按照数的大小排序,而是按照数字字符的排序。我是懒的找选项了,直接用眼睛找的,结果不多。
eexpress 写了:练习脚本。。。结果应该自动sort吧。
aloha
帖子: 375
注册时间: 2006-10-11 20:41

Re: 这是怎么回事?

#12

帖子 aloha » 2007-04-20 16:32

我这里又试了试,没毛病。要不你再重新拷一遍脚本。
记得apt-get install curl
hanben2000 写了:benny@ubuntu:~$ bash searh.sh
:找不到命令ne 2:
:找不到命令ne 3:
:找不到命令ne 4:
:找不到命令ne 5:
:找不到命令ne 6:
”附近出现语法错误: 在未预料的“
'earh.sh: line 14: `done
ziyun
帖子: 262
注册时间: 2007-03-29 12:59

#13

帖子 ziyun » 2007-04-20 17:25

楼主的脚本在我这里执行要将单引号改为双引号
yangyang
帖子: 555
注册时间: 2007-03-20 12:50

#14

帖子 yangyang » 2007-04-23 19:23

请问下,找到最快的源后如何查把源的列表呀?要如何把源加进去呢?
yangyang
帖子: 555
注册时间: 2007-03-20 12:50

#15

帖子 yangyang » 2007-04-23 19:24

比如说找到http://lug.mtu.edu/ubuntu/最快,哪如何查看这个源呀??

不会是在就加上http://lug.mtu.edu/ubuntu/吧??
回复