Wednesday, January 29, 2014

Package caching for debian based distros

Most of our computers run on linux, actually on debian based distros like ubuntu. To make installing and updating faster we have an apt proxy installed.

An apt proxy fetches files from remote repositories when needed, and caches them for local use. So it also saves bandwidth, which was very important before we had a fiber channel connection.
There are different apt proxies available, like apt-cacher, apt-cacher-ng, squid-deb-proxy or approx, which is the one we are using. It's easy to set up and works very well.

$ apt-get install approx

and the config file is

/etc/approx/approx.conf:

ubuntu    http://archive.ubuntu.com/ubuntu
ubuntu-extras    http://extras.ubuntu.com/ubuntu
ubuntu-partner    http://archive.canonical.com/ubuntu
ubuntu-security    http://security.ubuntu.com/ubuntu
debian    http://ftp.debian.org/debian
debian-security    http://security.debian.org/debian-security


Usually you only need to add your repositories. Of course there are other things that can be changed, like the port, or debugging. Just see $ man approx
Once it's running you can set up the client side.

So edit /etc/apt/sources appropriately. It could look like this:

deb http://proxy:9999/ubuntu precise main restricted multiverse universe
deb http://proxy:9999/ubuntu precise-security main restricted multiverse universe
deb http://proxy:9999/secure precise-security main restricted multiverse universe
deb http://proxy:9999/partner precise partner

Then run
$ apt-get update

That's mainly it. By the way, there are two apt related packages, that are very helpful.

apticron - it keeps you informed by email, if updates are available.
cron-apt - it downloads packages to your machine, and even installs them if you configure it that way.

No comments:

Post a Comment