Difference between revisions of "Mirrors (简体中文)"

From ArchWiki
Jump to: navigation, search
(rm temporary i18n template)
(use https for links to archlinux.org)
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:简体中文]]
 
 
[[Category:About Arch (简体中文)]]
 
[[Category:About Arch (简体中文)]]
 
[[Category:Package management (简体中文)]]
 
[[Category:Package management (简体中文)]]
Line 6: Line 5:
 
[[fr:Miroirs]]
 
[[fr:Miroirs]]
 
[[it:Mirrors]]
 
[[it:Mirrors]]
{{translateme (简体中文)}}
+
{{Article summary start|摘要}}
 
+
{{Article summary text|更新和管理软件包镜像}}
{{Article summary start|Summary}}
+
{{Article summary heading|相关}}
{{Article summary text|Updating and managing package mirrors}}
+
{{Article summary wiki|Mirroring}}
{{Article summary heading|Related}}
+
 
{{Article summary wiki|pacman}}
 
{{Article summary wiki|pacman}}
 
{{Article summary wiki|reflector}}
 
{{Article summary wiki|reflector}}
Line 19: Line 17:
 
== 启用您喜爱的镜像 ==
 
== 启用您喜爱的镜像 ==
  
想要启用镜像,打开 {{ic|/etc/pacman.d/mirrorlist}} 并定位到你的地理区域。取消注释您想使用的镜像。
+
想要启用镜像,打开 {{ic|/etc/pacman.d/mirrorlist}} 并定位到你的地理区域。对您想使用的镜像取消注释。
{{注意 | ftp.archlinux.org [http://www.archlinux.org/news/302/ 限速 50KB/s]}}  例如:
+
{{注意 | ftp.archlinux.org [https://www.archlinux.org/news/302/ 限速 50KB/s]}}  例如:
  
 
  # Any
 
  # Any
Line 28: Line 26:
 
参见 [[#镜像状态]] 和 [[#按速度排序]] 查看帮助选择镜像的工具。
 
参见 [[#镜像状态]] 和 [[#按速度排序]] 查看帮助选择镜像的工具。
  
{{小贴士|取消注释5个你最喜欢的镜像,把他们放在 mirrorlist 文件最上方。这样你就很容易找到它们并且如果第一个镜像出问题可以很容易切换。这也让合并 mirrorlist 更新更容易。}}
+
{{小贴士|取消5个你最喜欢的镜像的注释,把他们放在 mirrorlist 文件最上方。这样你就很容易找到它们并且如果第一个镜像出问题可以很容易切换。这也让合并 mirrorlist 更新更容易。}}
  
 
也可以在 {{ic|/etc/pacman.conf}} 中指定镜像。对于 ''[core]'' 仓库,默认设置是:
 
也可以在 {{ic|/etc/pacman.conf}} 中指定镜像。对于 ''[core]'' 仓库,默认设置是:
Line 39: Line 37:
 
  Include = /etc/pacman.d/mirrorlist
 
  Include = /etc/pacman.d/mirrorlist
  
pacman 会首先尝试链接这个镜像。继续在 ''[testing]'', ''[extra]'', 和 ''[community]''仓库添加同样一行,如果需要的话。
+
pacman 会首先尝试链接这个镜像。如果需要的话,可以继续修改''[testing]'', ''[extra]'', 和 ''[community]''部分。
  
 
{{注意|如果镜像直接在 {{ic|pacman.conf}} 中声明,记得在所有的仓库使用同样的镜像。否则不相容的包就可能被安装。如 ''[core]'' 中的 linux 和 ''[extra]'' 中的旧的内核模块不相容。}}
 
{{注意|如果镜像直接在 {{ic|pacman.conf}} 中声明,记得在所有的仓库使用同样的镜像。否则不相容的包就可能被安装。如 ''[core]'' 中的 linux 和 ''[extra]'' 中的旧的内核模块不相容。}}
  
 
==镜像状态==
 
==镜像状态==
Check the status of the Arch mirrors and how updated they are by visiting http://www.archlinux.de/?page=MirrorStatus or http://www.archlinux.org/mirrors/status/.
+
可以通过访问如下网址检查镜像的状态:
 +
* https://www.archlinux.org/mirrors/status/
 +
* http://www.archlinux.de/?page=MirrorStatus
  
You can generate an up to date mirrorlist [http://www.archlinux.org/mirrorlist/ here], automate the process with a [[#Script to automate use of Pacman Mirrorlist Generator|script]], or install [[Reflector]], a utility that generates a mirrorlist using Mirrorcheck's list; you can also manually check how up-to-date a mirror is by:
+
[https://www.archlinux.org/mirrorlist/ 这里]可以自动生成最新的镜像列表,安装[[Reflector]]这个工具也可以自动检查和生成镜像列表。
#picking a server and browsing to "extra/os/";
+
#accessing http://www.archlinux.org/ in another browser tab or window; and
+
#comparing the last-modified date of the {{ic|i686}} directory on the mirror to the ''[extra]'' date on the homepage, in the ''Package Repositories'' box to the right.
+
  
 
==镜像排序==
 
==镜像排序==
If not using reflector, which has the ability to sort mirrors by both how updated they are and their speed, follow this demonstration of manual mirror sorting.
 
 
 
===按速度排序===
 
===按速度排序===
Take full advantage of using the fastest local mirror, which can be determined via the included Bash script, {{ic|/usr/bin/rankmirrors}}.
+
更快的源可以显著的提升pacman的性能,和arch的整体操作体验。可以使用 {{ic|rankmirrors}} 将镜像列表按速度排列。但是{{ic|rankmirrors}}不能测试这些源的速度。
  
Use {{Ic|cd}} to switch to the {{ic|/etc/pacman.d}} directory:
+
{{ic|cd}}{{ic|/etc/pacman.d/}}目录:
# cd /etc/pacman.d
+
{{bc|# cd /etc/pacman.d}}
  
Back up the existing {{ic|/etc/pacman.d/mirrorlist}}:
+
备份已经存在的{{ic|/etc/pacman.d/mirrorlist}}:
# cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
+
{{bc|# cp mirrorlist mirrorlist.backup}}
  
Edit {{ic|/etc/pacman.d/mirrorlist.backup}} and uncomment mirrors for testing with {{ic|rankmirrors}}.
+
编辑{{ic|/etc/pacman.d/mirrorlist.backup}},取消要测速镜像前的注释。
  
Optionally run the following {{Ic|sed}} line to uncomment every mirror:
+
让rankmirrors带上参数{{ic|-n}}对这个备份文件{{ic|mirrorlist.backup}}执行操作,然后把输出重定向以方便生成一个新的/etc/pacman.d/mirrorlist源列表:
# sed '/^#\S/ s|#||' -i /etc/pacman.d/mirrorlist.backup
+
{{bc|# rankmirrors -n 6 mirrorlist.backup > mirrorlist}}
 +
{{注意|'''-n 6''':将生成6个最接近的源,运行{{Ic|rankmirrors -h}}可查看所有可用选项。}}
  
Finally, rank the mirrors. Operand {{Ic|-n 6}} means only output the 6 fastest mirrors:
+
'''强制 pacman 刷新软件包列表'''
# rankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist
+
 
+
Run {{Ic|rankmirrors -h}} for a list of all the available options.
+
 
+
'''Force pacman to refresh the package lists'''<br>
+
After creating/editing {{ic|/etc/pacman.d/mirrorlist}}, (manually or by using {{Ic|rankmirrors}}) issue the following command:
+
 
  # pacman -Syy
 
  # pacman -Syy
  
{{Tip|Passing two {{Ic|--refresh}} or {{Ic|-y}} flags forces pacman to refresh all package lists even if they are considered to be up to date. Issuing {{Ic|pacman -Syy}} ''whenever changing to a new mirror'' is good practice and will avoid possible issues.}}
+
{{Tip|传入两次{{Ic|--refresh}}{{Ic|-y}}将强制更新所有软件包列表,即使系统认为它们已经是最新。'''每次修改镜像之后都应该使用{{Ic|pacman -Syy}}'''}}
  
 
===按速度和状态排序===
 
===按速度和状态排序===
 +
{{translateme (简体中文)}}
 
It is not a good idea to just use the fastest mirrors, since the fastest mirrors might be out of date. The preferred way would be to use [[#按速度排序]], then sorting those 6 fastest mirrors by their [[#镜像状态]].  
 
It is not a good idea to just use the fastest mirrors, since the fastest mirrors might be out of date. The preferred way would be to use [[#按速度排序]], then sorting those 6 fastest mirrors by their [[#镜像状态]].  
  
Line 87: Line 78:
  
 
===Script to automate use of Pacman Mirrorlist Generator===
 
===Script to automate use of Pacman Mirrorlist Generator===
You can use the following shell script to update your mirrors based on the rankings produced by the [http://www.archlinux.org/mirrorlist/ Pacman Mirrorlist Generator]. If you do not live in the United States, you can change the country variable.
+
You can use the following shell script to update your mirrors based on the rankings produced by the [https://www.archlinux.org/mirrorlist/ Pacman Mirrorlist Generator]. If you do not live in the United States, you can change the country variable.
  
 
{{hc|updatemirrors.sh|2=<nowiki>#!/bin/sh
 
{{hc|updatemirrors.sh|2=<nowiki>#!/bin/sh
Line 94: Line 85:
  
 
country='us'
 
country='us'
url="http://www.archlinux.org/mirrorlist/?country=$country&protocol=ftp&protocol=http&ip_version=4&use_mirror_status=on"
+
url="https://www.archlinux.org/mirrorlist/?country=$country&protocol=ftp&protocol=http&ip_version=4&use_mirror_status=on"
  
 
tmpfile=$(mktemp --suffix=-mirrorlist)
 
tmpfile=$(mktemp --suffix=-mirrorlist)
Line 111: Line 102:
 
===使用 Reflector===
 
===使用 Reflector===
  
Alternatively, you can use [[Reflector]] to automatically retrieve the latest mirrorlist from the [http://www.archlinux.org/mirrors/status/ MirrorStatus] page, filter the most up-to-date mirrors, sort them by speed and overwrite the file {{ic|/etc/pacman.d/mirrorlist}}.
+
[[Reflector]]工具可以从[https://www.archlinux.org/mirrors/status/ 镜像状态]页面自动获取最新的镜像列表,过滤掉未及时同步的镜像,然后按照速度排序覆盖{{ic|/etc/pacman.d/mirrorlist}}
  
 
==官方镜像==
 
==官方镜像==
Line 121: Line 112:
 
取消选中镜像前的注释然后:
 
取消选中镜像前的注释然后:
 
  # pacman -Syy
 
  # pacman -Syy
  # pacman -Sf pacman-mirrorlist
+
  # pacman -S --force pacman-mirrorlist
  
 
如果要将自己的镜像加入官方列表,请提出申请并将其加入下面的 [[#非官方镜像]] 列表。
 
如果要将自己的镜像加入官方列表,请提出申请并将其加入下面的 [[#非官方镜像]] 列表。
Line 127: Line 118:
 
如果碰到 {{ic|$arch}} 变量未定义的问题,请在 {{ic|/etc/pacman.conf}} 中加入:
 
如果碰到 {{ic|$arch}} 变量未定义的问题,请在 {{ic|/etc/pacman.conf}} 中加入:
 
  Architecture = auto
 
  Architecture = auto
 +
 +
=== 支持 IPv6 的镜像 ===
 +
[https://www.archlinux.org/mirrorlist/?country=all&protocol=http&ip_version=6 pacman 镜像列表生成工具] 可以用来查找当前的 IPv6 镜像。
  
 
==非官方镜像==
 
==非官方镜像==
Line 179: Line 173:
 
* http://archlinux.linuxfreedom.com - ''Contains numerous ISO images but does not contain the ISO dated 2011.08.19''
 
* http://archlinux.linuxfreedom.com - ''Contains numerous ISO images but does not contain the ISO dated 2011.08.19''
 
* http://mirror.pointysoftware.net/archlinux/
 
* http://mirror.pointysoftware.net/archlinux/
 
==可以使用 IPv6 的镜像==
 
*ftp.free.fr (France)
 
*patroklos.noc.ntua.gr (Greece)
 
*ftp.heanet.ie (Ireland)
 
*ftp.nluug.nl (Netherlands)
 
*ftp.surfnet.nl (Netherlands)
 
*http://mirror6.bjtu.edu.cn/archlinux (China)
 
*http://mirrors.inetutils.net/archlinux/ (Malaysia)
 
*http://mirror.ece.vt.edu/archlinux/ (Virginia, US)
 
  
 
==疑难解答==
 
==疑难解答==

Revision as of 01:17, 6 December 2012

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end

本页面说明如何选择和配置镜像,以及列出可用的镜像。

启用您喜爱的镜像

想要启用镜像,打开 /etc/pacman.d/mirrorlist 并定位到你的地理区域。对您想使用的镜像取消注释。

注意: ftp.archlinux.org 限速 50KB/s
例如:
# Any
# Server = ftp://mirrors.kernel.org/archlinux/$repo/os/$arch
Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch

参见 #镜像状态#按速度排序 查看帮助选择镜像的工具。

小贴士: 取消5个你最喜欢的镜像的注释,把他们放在 mirrorlist 文件最上方。这样你就很容易找到它们并且如果第一个镜像出问题可以很容易切换。这也让合并 mirrorlist 更新更容易。

也可以在 /etc/pacman.conf 中指定镜像。对于 [core] 仓库,默认设置是:

[core]
Include = /etc/pacman.d/mirrorlist

想要使用 HostEurope 镜像作为默认镜像,把它添加在 Include 行之前:

[core]
Server = ftp://ftp.hosteurope.de/mirror/ftp.archlinux.org/core/os/$arch
Include = /etc/pacman.d/mirrorlist

pacman 会首先尝试链接这个镜像。如果需要的话,可以继续修改[testing], [extra], 和 [community]部分。

注意: 如果镜像直接在 pacman.conf 中声明,记得在所有的仓库使用同样的镜像。否则不相容的包就可能被安装。如 [core] 中的 linux 和 [extra] 中的旧的内核模块不相容。

镜像状态

可以通过访问如下网址检查镜像的状态:

这里可以自动生成最新的镜像列表,安装Reflector这个工具也可以自动检查和生成镜像列表。

镜像排序

按速度排序

更快的源可以显著的提升pacman的性能,和arch的整体操作体验。可以使用 rankmirrors 将镜像列表按速度排列。但是rankmirrors不能测试这些源的速度。

cd/etc/pacman.d/目录:

# cd /etc/pacman.d

备份已经存在的/etc/pacman.d/mirrorlist:

# cp mirrorlist mirrorlist.backup

编辑/etc/pacman.d/mirrorlist.backup,取消要测速镜像前的注释。

让rankmirrors带上参数-n对这个备份文件mirrorlist.backup执行操作,然后把输出重定向以方便生成一个新的/etc/pacman.d/mirrorlist源列表:

# rankmirrors -n 6 mirrorlist.backup > mirrorlist
注意: -n 6:将生成6个最接近的源,运行rankmirrors -h可查看所有可用选项。

强制 pacman 刷新软件包列表

# pacman -Syy
Tip: 传入两次--refresh-y将强制更新所有软件包列表,即使系统认为它们已经是最新。每次修改镜像之后都应该使用pacman -Syy

按速度和状态排序

Tango-preferences-desktop-locale.png本页面需要更新翻译,内容可能已经与英文脱节。要贡献翻译,请访问简体中文翻译组Tango-preferences-desktop-locale.png

附注: please use the first argument of the template to provide more detailed indications.

It is not a good idea to just use the fastest mirrors, since the fastest mirrors might be out of date. The preferred way would be to use #按速度排序, then sorting those 6 fastest mirrors by their #镜像状态.

Simply visit either one or both #镜像状态 links and sort them by the ones that are more up to date. Move the more up to date mirrors to the top of /etc/pacman.d/mirrorlist and if the mirrors are way out of date simply do not use those; repeat the process leaving out the outdated mirrors. So this ends up with a total of 6 mirrors that are sorted by speed and status, leaving out outdated mirrors.

When having mirror issues the above should be repeated. Or repeat once in a while even if not having mirror problems, to keep /etc/pacman.d/mirrorlist up to date.

Script to automate use of Pacman Mirrorlist Generator

You can use the following shell script to update your mirrors based on the rankings produced by the Pacman Mirrorlist Generator. If you do not live in the United States, you can change the country variable.

updatemirrors.sh
#!/bin/sh

[ "$UID" != 0 ] && su=sudo

country='us'
url="https://www.archlinux.org/mirrorlist/?country=$country&protocol=ftp&protocol=http&ip_version=4&use_mirror_status=on"

tmpfile=$(mktemp --suffix=-mirrorlist)

# Get latest mirror list and save to tmpfile
wget -qO- "$url" | sed 's/^#Server/Server/g' > "$tmpfile"

# Backup and replace current mirrorlist file
{ echo "Backing up the original mirrorlist..."
  $su mv -i /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.orig; } &&
{ echo "Rotating the new list into place..."
  $su mv -i "$tmpfile" /etc/pacman.d/mirrorlist; }
Note: You will need to copy the text above, place it into a file, and run chmod +x on the file. If you are not currently logged in as root, the script will invoke sudo for you when it needs to rotate the new mirrorlist into place.

使用 Reflector

Reflector工具可以从镜像状态页面自动获取最新的镜像列表,过滤掉未及时同步的镜像,然后按照速度排序覆盖/etc/pacman.d/mirrorlist

官方镜像

官方镜像可以通过软件包 pacman-mirrorlist 获得。最新的镜像可以通过Pacman 镜像列表生成器查询。

如果没有配置任何镜像,也没有安装 pacman-mirrorlist,请运行如下命令:

# wget -O /etc/pacman.d/mirrorlist https://www.archlinux.org/mirrorlist/all/

取消选中镜像前的注释然后:

# pacman -Syy
# pacman -S --force pacman-mirrorlist

如果要将自己的镜像加入官方列表,请提出申请并将其加入下面的 #非官方镜像 列表。

如果碰到 $arch 变量未定义的问题,请在 /etc/pacman.conf 中加入:

Architecture = auto

支持 IPv6 的镜像

pacman 镜像列表生成工具 可以用来查找当前的 IPv6 镜像。

非官方镜像

These mirrors are not listed in /etc/pacman.d/mirrorlist.

全球

保加利亚

中国

  1. CHINA TELECOM
  1. CHINA UNICOM

德国

印度尼西亚

立陶宛

马来西亚

新西兰

俄罗斯

南非

美国

疑难解答

Out-of-sync mirrors: corrupted packages/file not found

Issues regarding out-of-sync mirrors pointed out in this news post may have already been sorted out for most users, but in the event that problems of this nature present themselves again, simply try to see if the packages are present in the [testing] repository.

After having synced with pacman -Sy, use this command:

# pacman -Ud $(pacman -Sup | tail -n +2 | sed -e 's,/\(core\|extra\)/,/testing/,' \
                                              -e 's,/\(community\)/,/\1-testing/,')

Doing so could help in any occasion where packages in the mirror have not been synced to [core] or [extra], and are still residing in [testing]. It is perfectly safe to install from [testing] in this case since the packages are being matched by version and release numbers.

In any event, it is best to switch mirrors and sync with pacman -Syy than resorting to an alternate repository. However, all or some of the mirrors may at times be out-of-sync to some degree.

使用所有镜像

To emulate pacman -Su's behavior of going through the entire mirror list, use this script:

~/bin/pacup
#!/bin/bash

# Pacman will not exit on the first error. Comment the line below to
# try from [testing] directly.
pacman -Su "$@" && exit

while read -r pkg; do
  if pacman -Ud "$pkg"; then
    continue
  else
    while read -r mirror; do
      pacman -Ud $(sed "s,.*\(/\(community-\)*testing/os/\(i686\|x86_64\)/\),$mirror\1," <<<"$pkg") &&
      break
    done < <(sed -ne 's,^ *Server *= *\|/$repo/os/\(i686\|x86_64\).*,,gp' \
           </etc/pacman.d/mirrorlist | tail -n +2 )
  fi
done < <(pacman -Sup | tail -n +2 | sed -e 's,/\(core\|extra\)/,/testing/,' \
                                        -e 's,/\(community\)/,/\1-testing/,')

Checking multiple mirrors with paccheck

The paccheck script can be used:

  • to compare pacman sync databases and package desc files to different mirrors,
  • to verify size of packages in pacman cache
  • to optionally compare packages in pacman cache to selected mirror(s).

The script is intended to help to detect compromised mirrors, before the official implementation of package signing. It is destined for those who may want a little more assurance against some possible hacking scenarios of mirror servers.

The Full System Update Procedure is:

  1. Run paccheck as a non-root user. Pacman will be synchronised and the needed packages will be downloaded.
  2. Examine report
  3. If no package mismatch, then run pacman -Su as root to update your system

The script can be found in the AUR: paccheckAUR

参见

  • [MirUp] -- pacman mirrorlist downloader/checker