| Using apt-proxy to reduce bandwidth and increase speed |
| Articles & Information - Tech Talk | |
What is apt-proxy? apt-proxy is a program (daemon) that stores regularly downloaded debian and debian-based (Ubuntu) package files. This is useful when there are multiple debian systems on the same network. Any updates pulled down for one machine from the Internet will be made available to all machines locally which reduces required bandwidth and increases speed. How do I set up the apt-proxy server?To install the package: "apt-get install apt-proxy" then check / modify the configuration. Recent versions use the configuration file: /etc/apt-proxy/apt-proxy-v2.conf This file contains sections for each type of package source which enables caching of different flavours (Debian, Ubuntu etc) and also different sources (backports, security etc). A section looks like this: [debian]This has been set up to use the Virgin Media local Debian cache then the main UK debian site. As many backends as needed can be specified in order of preference. There are many examples in the default configuration file which allow it to work out of the box. However, it is always worth learning some local caches for your country, region or connection provider. Some un-documented but useful additions are: [backports] (Formerly backports.org) apt-proxy will automatically work out which particular version you have based on the client configuration so you do not need to specify configuration sections for lenny, squeeze and so on. There are other configuration settings but generally these can be left as default. The most notable setting to be aware of is the server port to listen on. By default, this is set to: "port = 9999". Once the configuration has been updated, restart apt-proxy: " /etc/init.d/apt-proxy restart" How do I set up client systems to use apt-proxy serverEdit your sources file ( /etc/apt/sources.list) and comment out all of the existing sources with a # symbol. You will need to change the example servername to the IP address or hostname of the machine you have set up for apt-proxy.You will also need to know the port that the server is configured against. By default, this is 9999. Here are some example client configuration: Debian Lenny using apt-proxy# apt-proxy for Lenny Debian Squeeze using apt-proxy# apt-proxy for Squeeze Ubuntu Maverick using apt-proxydeb http://apt-proxy:9999/ubuntu maverick main restricted universe multiverse Debian Etch using apt-proxy Debian Etch needs to be treated differently as the repository has been migrated from the main deb servers to the archive. In order to make this work, we need to be creative. The suffix of the deb url specifies which section in the apt-proxy is used for this request. We usually use "/debian" for standard releases. Since the backends under the [debian] section no longer support Etch, we need to add another one with a different suffix as follows: [archive] Then use the following line in your sources.list: deb http://apt-proxy:9999/archive etch main contrib non-free Making use of the new apt-proxy configuration Once the sources have been set up, run "apt-get update" to load the indexes via the proxy then "apt-get upgrade" to update or install packages . These may need to be pre-fixed with "sudo" on ubuntu. The first time a package is loaded in to the proxy, you will probably not experience any benefit. However, on the second and subsequent systems, the performance will be increased dramatically. TroubleshootingDebugging levels can be set within the configuration file. The working output can be found in the logfile: /var/log/apt-proxy.log Due to the way apt works, there are few useful errors at the client if there are server issues. If you find long timeouts whilst waiting for headers at the client, it is likely that you have a misconfigured backend on the apt-proxy. These can be tricky to spot so careful examination may be needed. Example problemsError: Err http://apt-proxy lenny Release.gpg Cause: This is caused by a backend set up at the client that does not exist at the server. Error: Err http://apt-proxy lenny Release.gpg Cause: The servername is not correct Error: Err http://apt-proxy lenny Release.gpg Cause: Port number not correct or server not running on the host Error: 0% [Waiting for headers] Cause: The requested distribution may not be valid or available via the backends configured. Note:At the time of writing, apt-proxy is not available on Squeeze. The lenny package can be installed if required. Alternatives to apt-proxyapt-cacher is a newer and more frequently updated apt-proxy system and is directly client-compatible with apt-proxy. However, apt-cacher cannot manage different deb-based distributions simultaneously so multiple servers are needed to manage Debian and Ubuntu clients. |
|