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

From ArchWiki
Jump to: navigation, search
(use https for links to archlinux.org)
(示例)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[Category:Package management (简体中文)]]
 
[[Category:Package management (简体中文)]]
 
[[en:Reflector]]
 
[[en:Reflector]]
 +
[[es:Reflector]]
 +
[[fr:Reflector]]
 +
[[it:Reflector]]
 +
[[ja:Reflector]]
 
[[ko:Reflector]]
 
[[ko:Reflector]]
 
[[ru:Reflector]]
 
[[ru:Reflector]]
Line 6: Line 10:
  
 
==安装==
 
==安装==
{{pkg|reflector}} 软件包位于[[Official Repositories (简体中文)|官方软件源]],可以直接[[pacman (简体中文)|安装]]
+
[[安装]]软件包 {{pkg|reflector}}。
  
# pacman -S reflector
+
==用法==
 +
{{警告|
 +
* 在下面的例子中, {{ic|/etc/pacman.d/mirrorlist}} 会被覆盖。在运行之前请先备份。
 +
*同步或更新 [[Pacman]]前请确保 {{ic|/etc/pacman.d/mirrorlist}}不包含任何奇怪的内容.}}
  
==使用示例==
+
To see all of the available commands, run the following command:
先备份 {{ic|/etc/pacman.d/mirrorlist}}::
+
  # reflector --help
  # cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
+
  
下面命令将过滤出 5 个镜像,按速度排列并覆盖 {{ic|/etc/pacman.d/mirrorlist}}:
+
=== 示例 ===
# reflector -l 5 --sort rate --save /etc/pacman.d/mirrorlist
+
  
要查看所有命令,请运行
+
通过下载速度进行排序,筛选前五位镜像并写入到{{ic|/etc/pacman.d/mirrorlist}}:
  # reflector --help
+
  # reflector --verbose -l 5 --sort rate --save /etc/pacman.d/mirrorlist
 +
 
 +
Verbosely rate the 200 most recently synchronized HTTP servers, sort them by download rate, and overwrite the file {{ic|/etc/pacman.d/mirrorlist}}:
 +
 
 +
# reflector --verbose -l 200 -p http --sort rate --save /etc/pacman.d/mirrorlist
 +
 
 +
Verbosely rate the 200 most recently synchronized HTTPS servers located in the US, sort them by download rate, and overwrite the file {{ic|/etc/pacman.d/mirrorlist}}:
 +
 
 +
# reflector --verbose --country 'United States' -l 200 -p https --sort rate --save /etc/pacman.d/mirrorlist
 +
 
 +
=== Systemd Service ===
 +
 
 +
{{hc|/etc/systemd/system/reflector.service|<nowiki>
 +
[Unit]
 +
Description=Pacman mirrorlist update
 +
 
 +
[Service]
 +
Type=oneshot
 +
ExecStart=/usr/bin/reflector --protocol https --latest 30 --number 20 --sort rate --save /etc/pacman.d/mirrorlist
 +
</nowiki>}}
 +
 
 +
Then [[start]]ing {{ic|reflector.service}} will update your mirrorlist.
 +
 
 +
To update your mirrorlist every time your computer boots you can enable the following service definition.
 +
 
 +
{{hc|/etc/systemd/system/reflector.service|<nowiki>
 +
[Unit]
 +
Description=Pacman mirrorlist update
 +
Requires=network-online.target
 +
After=network-online.target
 +
 
 +
[Service]
 +
Type=oneshot
 +
ExecStart=/usr/bin/reflector --protocol https --latest 30 --number 20 --sort rate --save /etc/pacman.d/mirrorlist
 +
 
 +
[Install]
 +
RequiredBy=multi-user.target
 +
</nowiki>}}
 +
 
 +
Make sure you [http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/ activate the appropriate services] so that {{ic|network.target}} really reflects your network status.
 +
 
 +
=== Systemd 定时 ===
 +
 
 +
如果你想每周一次运行 {{ic|reflector.service}}:
 +
 
 +
{{hc|/etc/systemd/system/reflector.timer|<nowiki>
 +
[Unit]
 +
Description=Run reflector weekly
 +
 
 +
[Timer]
 +
OnCalendar=weekly
 +
RandomizedDelaySec=12h
 +
Persistent=true
 +
 
 +
[Install]
 +
WantedBy=timers.target
 +
</nowiki>}}
 +
 
 +
然后仅需 [[start|启动]]{{ic|reflector.timer}}.
 +
 
 +
==== AUR  ====
 +
 
 +
[[Install]] the {{AUR|reflector-timer}} package to run ''reflector'' daily, or install the {{AUR|reflector-timer-weekly}} to run it weekly.
 +
 
 +
===== reflector-timer =====
 +
 
 +
The default configuration is:
 +
{{hc|/usr/share/reflector-timer/reflector.conf|<nowiki>
 +
AGE=6
 +
COUNTRY=Germany
 +
LATEST=30
 +
NUMBER=20
 +
SORT=rate
 +
</nowiki>}}
 +
 
 +
To override this configuration, edit {{ic|/etc/conf.d/reflector.conf}}:
 +
{{hc|/etc/conf.d/reflector.conf|<nowiki>
 +
COUNTRY=US
 +
</nowiki>}}
 +
 
 +
Be sure to [[enable]] {{ic|reflector.timer}}.
 +
 
 +
===== reflector-timer-weekly =====
 +
 
 +
The default configuration is:
 +
{{hc|/etc/reflector.conf|<nowiki>
 +
--save /etc/pacman.d/mirrorlist
 +
--country China
 +
--sort rate
 +
</nowiki>}}
  
{{警告|同步或者更新前请保证 mirrorlist 不包含任何奇怪的内容。}}
+
Each line (except that begins with '#') should be valid {{ic|reflector}} option.
  
==外部链接==
+
Be sure to [[enable]] {{ic|reflector.timer}}.
*项目官方页面: http://xyne.archlinux.ca/projects/reflector/
+

Latest revision as of 08:41, 15 July 2016

Reflector 是一个脚本程序,从镜像状态页面获取镜像列表,过滤出还在更新的页面并根据速度排列,然后覆盖文件/etc/pacman.d/mirrorlist

安装

安装软件包 reflector

用法

警告:
  • 在下面的例子中, /etc/pacman.d/mirrorlist 会被覆盖。在运行之前请先备份。
  • 同步或更新 Pacman前请确保 /etc/pacman.d/mirrorlist不包含任何奇怪的内容.

To see all of the available commands, run the following command:

# reflector --help

示例

通过下载速度进行排序,筛选前五位镜像并写入到/etc/pacman.d/mirrorlist:

# reflector --verbose -l 5 --sort rate --save /etc/pacman.d/mirrorlist

Verbosely rate the 200 most recently synchronized HTTP servers, sort them by download rate, and overwrite the file /etc/pacman.d/mirrorlist:

# reflector --verbose -l 200 -p http --sort rate --save /etc/pacman.d/mirrorlist

Verbosely rate the 200 most recently synchronized HTTPS servers located in the US, sort them by download rate, and overwrite the file /etc/pacman.d/mirrorlist:

# reflector --verbose --country 'United States' -l 200 -p https --sort rate --save /etc/pacman.d/mirrorlist

Systemd Service

/etc/systemd/system/reflector.service
[Unit]
Description=Pacman mirrorlist update

[Service]
Type=oneshot
ExecStart=/usr/bin/reflector --protocol https --latest 30 --number 20 --sort rate --save /etc/pacman.d/mirrorlist

Then starting reflector.service will update your mirrorlist.

To update your mirrorlist every time your computer boots you can enable the following service definition.

/etc/systemd/system/reflector.service
[Unit]
Description=Pacman mirrorlist update
Requires=network-online.target
After=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/bin/reflector --protocol https --latest 30 --number 20 --sort rate --save /etc/pacman.d/mirrorlist

[Install]
RequiredBy=multi-user.target

Make sure you activate the appropriate services so that network.target really reflects your network status.

Systemd 定时

如果你想每周一次运行 reflector.service:

/etc/systemd/system/reflector.timer
[Unit]
Description=Run reflector weekly

[Timer]
OnCalendar=weekly
RandomizedDelaySec=12h
Persistent=true

[Install]
WantedBy=timers.target

然后仅需 启动reflector.timer.

AUR

Install the reflector-timerAUR package to run reflector daily, or install the reflector-timer-weeklyAUR to run it weekly.

reflector-timer

The default configuration is:

/usr/share/reflector-timer/reflector.conf
AGE=6
COUNTRY=Germany
LATEST=30
NUMBER=20
SORT=rate

To override this configuration, edit /etc/conf.d/reflector.conf:

/etc/conf.d/reflector.conf
COUNTRY=US

Be sure to enable reflector.timer.

reflector-timer-weekly

The default configuration is:

/etc/reflector.conf
--save /etc/pacman.d/mirrorlist
--country China
--sort rate

Each line (except that begins with '#') should be valid reflector option.

Be sure to enable reflector.timer.