AptProxyHowTo

参与到Ubuntu的翻译中来
回复
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

AptProxyHowTo

#1

帖子 oneleaf » 2005-08-02 11:10

AptProxyHowTo
How to install apt-proxy
Introduction

apt-proxy is a proxy for apt that creates a complete copy of the remote repository on your hard disk. As apt-proxy behaves as if it was a HTTP-Server with a repository, you can access the packages from every other computer in your intranet. If a package is not in the cache, apt-proxy automatically downloads it and puts it to the cache. This may significantly decrease download bandwith and installation time if you have to install packages over and over again (i.e. an upgrade or dist-upgrade of all your machines).

The current unstable version of apt-proxy is available from the hoary universe repository (See: [WWW] How To - Access the "universe" repository) and you can simply install it via

apt-get install apt-proxy/hoary

Configuration

To use apt-proxy, you have to change apt's sources.list and the configuration of apt-proxy.
apt-proxy-v2.conf

The first section in /etc/apt-proxy/apt-proxy-v2.conf contains the default settings for the proxy and its cache.

Most probably you want to change the address parameter to something appropriate for you, namely the IP of your proxy server in the internal network. The port parameter specifies the port apt-proxy listens on for requests and defaults to 9999 wich is a good value to stay at if you don't have any conflicts.

Maybe you want to change the cache directory of the repository to some other place than /var/cache/apt-proxy. This can be done by changing the cache_dir parameter.

If you are using a general proxy, you can make apt-proxy aware of it with http_proxy = proxy_server:port. If you are behind a firewall you may experience problems with active FTP connections when trying to connect to a FTP backend. passive_ftp = on should solve this problem.

The other values control the time a package remains in the cache, how old a package must be at least before apt-proxy checks for newer versions or how often the cache is checked for old packages. They can safely be left on their default values.

apt-proxy has to know where to find the remote repository, named backend. This is done via backend sections in /etc/apt-proxy/apt-proxy-v2.conf. A backend entry for ubuntu may look like this:

[ubuntu]
;; Ubuntu archive
backends =
http://archive.ubuntu.com/ubuntu
http://de.archive.ubuntu.com/ubuntu

As you can see, it is possible to specify more than one server, separated by blank space. If the first server should be down, apt-proxy tries to get the data from the second server and so on.You can also override values set in the [default-section. For instance, if you know that a special server takes very long to answer a request, you can increase the timeout value:

[ubuntu-slow]
timout = 60 ;wait 1 Minute
backends = prot://some.very.slow.server.net/ubuntu-slow

A complete apt-proxy-v2.conf (i.e. mine ;-)) may look like this:

[DEFAULT]
;; All times are in seconds, but you can add a suffix
;; for minutes(m), hours(h) or days(d)

address = 127.0.0.1
port = 9999
cache_dir = /var/cache/apt-proxy

;; Control files (Packages/Sources/Contents) refresh rate
min_refresh_delay = 1s
complete_clientless_downloads = 1

;; Debugging settings.
debug = all:4 db:0

timeout = 30
passive_ftp = on

;;--------------------------------------------------------------
;; Cache housekeeping

cleanup_freq = 1d
max_age = 120d
max_versions = 3

;;---------------------------------------------------------------
;; Backend servers
;;
;; Place each server in its own [section]

[ubuntu]
; Ubuntu archive
backends =
http://archive.ubuntu.com/ubuntu
http://de.archive.ubuntu.com/ubuntu

[ubuntu-security]
; Ubuntu security updates
backends = http://security.ubuntu.com/ubuntu

[marillat]
backends = ftp://ftp.nerim.net/debian-marillat

[debian]
; Backend servers, in order of preference
backends =
http://ftp.us.debian.org/debian
http://ftp.de.debian.org/debian
http://ftp2.de.debian.org/debian
ftp://ftp.uk.debian.org/debian

[debian-non-US]
; Debian debian-non-US archive
backends =
http://ftp.uk.debian.org/debian-non-US
http://ftp.de.debian.org/debian-non-US
ftp://ftp.uk.debian.org/debian

[security]
; Debian security archive
backends =
http://security.debian.org/debian-security
http://ftp2.de.debian.org/debian-security

[openoffice]
; OpenOffice.org packages
backends =
http://ftp.囗囗囗囗囗囗囗.de/pub/debian-openoffice
http://ftp.sh.cvut.cz/MIRRORS/OpenOffice.deb
http://borft.student.utwente.nl/debian

[apt-proxy]
; Apt-proxy new versions
backends = http://apt-proxy.sourceforge.net/apt-proxy

sources.list

Now, apt has to know that there is something like apt-proxy to get the packages from instead of downloading them directly. It is the best if you comment all direct servers in your sources.list out to make sure that apt-get never tries to get packages directly from a server. Then add the lines for apt-proxy. They look similar to normal apt repositories except that you always have to append the backend section (the items in square brackets in apt-proxy-v2.conf) as path:

deb http://apt-proxy:port/backend dist component

If your apt-proxy listens on localhost on port 9999, as mine does, and you specified a section ubuntu, a source line might look like this:

deb http://localhost:9999/ubuntu hoary main restricted universe multiverse
deb-src http://localhost:9999/ubuntu hoary main restricted universe multiverse
^^^^^^
This is the backend section (i.e. [ubuntu])

After you changed the apt-proxy configuration file, you must restart the proxy by sudo-ing

/etc/init.d/apt-proxy restart

The complete sources.list corresponding to the apt-proxy-v2.conf above may look like this:

# apt-proxy entries for standard modules
deb http://localhost:9999/ubuntu hoary main restricted universe multiverse
deb-src http://localhost:9999/ubuntu hoary main restricted universe multiverse

# apt-proxy entries for security patches
deb http://localhost:9999/ubuntu-security hoary-security main restricted universe multiverse
deb-src http://localhost:9999/ubuntu-security hoary-security main restricted universe multiverse

# additional repositories
deb http://localhost:9999/marillat unstable main

# debian packages
deb http://localhost:9999/debian unstable main contrib non-free
deb http://localhost:9999/debian-non-US unstable/non-us main contrib non-free
deb http://localhost:9999/security sid main contrib non-free

Initializing apt-proxy

Now run a apt-get update to initialize apt-proxy's cache and get the new lists to the cache. Now you can use apt-* as if there were no apt-proxy.
Importing apt's cache

If you already downloaded packages with apt-get, they are cached in /var/cache/apt/archives. You can import these packages to the apt-proxy cache with apt-proxy-import according to the current package list. So you should first run apt-get update to get a fresh list. Then simply run

apt-proxy-import -r -i /var/cache/apt/archives

and apt-proxy will import all the packages in apt's cache to its own cache.
Links

*

[AptGetHowTo]
*

[WWW] http://apt-proxy.sourceforge.net


https://wiki.ubuntu.com/AptProxyHowTo
当净其意如虚空,远离妄想及诸取,令心所向皆无碍
头像
leal
帖子: 1119
注册时间: 2005-08-29 14:49
来自: 杭州
联系:

初译

#2

帖子 leal » 2005-08-31 23:50

viewtopic.php?t=1726

AptProxyHowTo
How to install apt-proxy
apt-proxy安装指南
Introduction
导言

apt-proxy is a proxy for apt that creates a complete copy of the remote repository on your hard disk. As apt-proxy behaves as if it was a HTTP-Server with a repository, you can access the packages from every other computer in your intranet. If a package is not in the cache, apt-proxy automatically downloads it and puts it to the cache. This may significantly decrease download bandwith and installation time if you have to install packages over and over again (i.e. an upgrade or dist-upgrade of all your machines).
apt-proxy是一个用于apt的代理,它可以在你的硬盘上创建一个远程仓库的完整副本。由于apt-proxy行为类似一个带有仓库的HTTP服务器,因此你可以在内部网的其它机器上访问这些包。如果cache中缺少某个包,apt-proxy会自动下载该包并把它放到cache中。如果你得一遍又一遍的安装 包(也即upgrade或dist-upgrade你的所有机器),apt-proxy可以很大程度上减少下载带宽和安装时间。

The current unstable version of apt-proxy is available from the hoary universe repository (See: [WWW] How To - Access the "universe" repository) and you can simply install it via
apt-proxy的当前不稳定版本可以从hoary universe仓库获得(参见:[WWW]如何-访问“universe”仓库),你可以通过如下命令快捷安装apt-proxy:

apt-get install apt-proxy/hoary

Configuration
配置

To use apt-proxy, you have to change apt's sources.list and the configuration of apt-proxy.
若要使用apt-proxy,你必须更改apt的sources.list和apt-proxy的配置文件。
apt-proxy-v2.conf

The first section in /etc/apt-proxy/apt-proxy-v2.conf contains the default settings for the proxy and its cache.
/etc/apt-proxy/apt-proxy-v2.conf的第一段包含了这个代理(apt-proxy)和其cache的缺省设置。

Most probably you want to change the address parameter to something appropriate for you, namely the IP of your proxy server in the internal network. The port parameter specifies the port apt-proxy listens on for requests and defaults to 9999 wich is a good value to stay at if you don't have any conflicts.
最应该做的更改是把地址(address)参数设置成适合你的值,也即你的代理服务器在内部网络的IP地址。端口(port)参数指定了apt-proxy要在哪个端口侦听请求,缺省值是9999,如果和系统其它设置不相冲突,那就最好别做改变。

Maybe you want to change the cache directory of the repository to some other place than /var/cache/apt-proxy. This can be done by changing the cache_dir parameter.
也许你想把仓库的cache目录设置成/var/cache/apt-proxy之外的目录,改变cache_dir参数可达此目的。

If you are using a general proxy, you can make apt-proxy aware of it with http_proxy = proxy_server:port. If you are behind a firewall you may experience problems with active FTP connections when trying to connect to a FTP backend. passive_ftp = on should solve this problem.
如果你正在使用一个普通代理(general proxy),设置http_proxy = proxy_server:port你可以令apt-proxy知道其存在。如果你处于防火墙后,那么试图连接到FTP后端时,使用主动(active)FTP连接可能会遇到问题。设置passive_ftp = on应该能解决这个问题。

The other values control the time a package remains in the cache, how old a package must be at least before apt-proxy checks for newer versions or how often the cache is checked for old packages. They can safely be left on their default values.
其它一些值控制包留存在cache中的时间、至少多久之后才让apt-proxy检查某个包的更新版本,或者在cache中检查旧包的频率(??need improve)。这些设置一般使用缺省值即可。

apt-proxy has to know where to find the remote repository, named backend. This is done via backend sections in /etc/apt-proxy/apt-proxy-v2.conf. A backend entry for ubuntu may look like this:
apt-proxy必须知道远端仓库的位置,即后端(backend)。可以在/etc/apt-proxy/apt-proxy-v2.conf的backend段中进行设置。ubuntu所用的backend项示例如下:

[ubuntu]
;; Ubuntu archive
backends =
http://archive.ubuntu.com/ubuntu
http://de.archive.ubuntu.com/ubuntu

As you can see, it is possible to specify more than one server, separated by blank space. If the first server should be down, apt-proxy tries to get the data from the second server and so on.You can also override values set in the [default-section. For instance, if you know that a special server takes very long to answer a request, you can increase the timeout value:
如你所见,可以指定不止一个服务器,由空格分隔。如果第一个服务器失效,apt-proxy会试着从第二个服务器获取数据,依此类推。你也可以根据default段的值集进行设置。比如,如果你知道某个服务器需很长时间应答请求,就可以增大timeout值:

[ubuntu-slow]
timout = 60 ;wait 1 Minute
backends = prot://some.very.slow.server.net/ubuntu-slow

A complete apt-proxy-v2.conf (i.e. mine Wink) may look like this:
完整的apt-proxy-v2.conf文件(这个是我的)和如下类似:

[DEFAULT]
;; All times are in seconds, but you can add a suffix
;; for minutes(m), hours(h) or days(d)

address = 127.0.0.1
port = 9999
cache_dir = /var/cache/apt-proxy

;; Control files (Packages/Sources/Contents) refresh rate
min_refresh_delay = 1s
complete_clientless_downloads = 1

;; Debugging settings.
debug = all:4 db:0

timeout = 30
passive_ftp = on

;;--------------------------------------------------------------
;; Cache housekeeping

cleanup_freq = 1d
max_age = 120d
max_versions = 3

;;---------------------------------------------------------------
;; Backend servers
;;
;; Place each server in its own [section]

[ubuntu]
; Ubuntu archive
backends =
http://archive.ubuntu.com/ubuntu
http://de.archive.ubuntu.com/ubuntu

[ubuntu-security]
; Ubuntu security updates
backends = http://security.ubuntu.com/ubuntu

[marillat]
backends = ftp://ftp.nerim.net/debian-marillat

[debian]
; Backend servers, in order of preference
backends =
http://ftp.us.debian.org/debian
http://ftp.de.debian.org/debian
http://ftp2.de.debian.org/debian
ftp://ftp.uk.debian.org/debian

[debian-non-US]
; Debian debian-non-US archive
backends =
http://ftp.uk.debian.org/debian-non-US
http://ftp.de.debian.org/debian-non-US
ftp://ftp.uk.debian.org/debian

[security]
; Debian security archive
backends =
http://security.debian.org/debian-security
http://ftp2.de.debian.org/debian-security

[openoffice]
; OpenOffice.org packages
backends =
http://ftp.囗囗囗囗囗囗囗.de/pub/debian-openoffice
http://ftp.sh.cvut.cz/MIRRORS/OpenOffice.deb
http://borft.student.utwente.nl/debian

[apt-proxy]
; Apt-proxy new versions
backends = http://apt-proxy.sourceforge.net/apt-proxy

sources.list

Now, apt has to know that there is something like apt-proxy to get the packages from instead of downloading them directly. It is the best if you comment all direct servers in your sources.list out to make sure that apt-get never tries to get packages directly from a server. Then add the lines for apt-proxy. They look similar to normal apt repositories except that you always have to append the backend section (the items in square brackets in apt-proxy-v2.conf) as path:
现在,apt必须知道系统上存在apt-proxy这玩意,并且可以从它那儿获取安装包,而非直接下载这些包。最好的办法是把sources.list里的所有直接服务器(注:即外部服务器,非内网)都注释掉,以确保apt-get决不会试图从这些服务器上直接获取包。然后添加apt-proxy设置,它们看上去和普通apt仓库相似,只不过你总是必须在其后添加backend段名(即apt-proxy-v2.conf中方括号内的所有项)以组成路径:

deb http://apt-proxy:port/backend dist component

If your apt-proxy listens on localhost on port 9999, as mine does, and you specified a section ubuntu, a source line might look like this:
如果你的apt-proxy和我的一样侦听localhost的9999端口,你可以指定一个ubuntu段,还有源(代码)行和如下类似:(注:need improve!)

deb http://localhost:9999/ubuntu hoary main restricted universe multiverse
deb-src http://localhost:9999/ubuntu hoary main restricted universe multiverse
^^^^^^ (注:^^^^^^^应移至这儿?)
This is the backend section (i.e. [ubuntu])
这是backend段(即[ubuntu])

After you changed the apt-proxy configuration file, you must restart the proxy by sudo-ing
在你更改apt-proxy配置文件后,你必须通过sudo操作重启这个代理:

/etc/init.d/apt-proxy restart

The complete sources.list corresponding to the apt-proxy-v2.conf above may look like this:
和上述apt-proxy-v2.conf对应的完整的sources.list如下:

# apt-proxy entries for standard modules
deb http://localhost:9999/ubuntu hoary main restricted universe multiverse
deb-src http://localhost:9999/ubuntu hoary main restricted universe multiverse

# apt-proxy entries for security patches
deb http://localhost:9999/ubuntu-security hoary-security main restricted universe multiverse
deb-src http://localhost:9999/ubuntu-security hoary-security main restricted universe multiverse

# additional repositories
deb http://localhost:9999/marillat unstable main

# debian packages
deb http://localhost:9999/debian unstable main contrib non-free
deb http://localhost:9999/debian-non-US unstable/non-us main contrib non-free
deb http://localhost:9999/security sid main contrib non-free

Initializing apt-proxy
初始化apt-proxy

Now run a apt-get update to initialize apt-proxy's cache and get the new lists to the cache. Now you can use apt-* as if there were no apt-proxy.
现在运行apt-get update来初始化apt-proxy的cache并把新的列表存入cache中。于是你便可以按老样子使用apt-*,好像根本没apt-proxy这玩意。

Importing apt's cache
导入apt的cache

If you already downloaded packages with apt-get, they are cached in /var/cache/apt/archives. You can import these packages to the apt-proxy cache with apt-proxy-import according to the current package list. So you should first run apt-get update to get a fresh list. Then simply run
如果你之前已经用apt-get下载过包,这些包会缓存在/var/cache/apt/archives目录里。根据当前的包列表,你可以用apt-proxy-import把这些包导入到apt-proxy cache中。(need improve!)因此你应该首先运行apt-get update得到最新列表,然后只需简单运行如下命令:

apt-proxy-import -r -i /var/cache/apt/archives

and apt-proxy will import all the packages in apt's cache to its own cache.
这样apt-proxy就会把apt cache里的所有包导入到它自己的cache中。
Links

*

[AptGetHowTo]
*

[WWW] http://apt-proxy.sourceforge.net


https://wiki.ubuntu.com/AptProxyHowTo
用心×恒 | 豆瓣 | 门户 | Blog
头像
millenniumdark
论坛版主
帖子: 4159
注册时间: 2005-07-02 14:41
系统: Ubuntu 14.04 (Kylin)
联系:

#3

帖子 millenniumdark » 2005-09-01 20:09

leal辛苦了

翻譯的很多,質量也不錯。
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

#4

帖子 oneleaf » 2005-09-07 20:17

当净其意如虚空,远离妄想及诸取,令心所向皆无碍
头像
millenniumdark
论坛版主
帖子: 4159
注册时间: 2005-07-02 14:41
系统: Ubuntu 14.04 (Kylin)
联系:

#5

帖子 millenniumdark » 2006-07-30 18:44

回复