Debian/Ubuntu Tips and Tricks

Debuntu

Debian/Ubuntu Tips and Tricks

How To Set up a repository cache with apt-cacher — page 2

Posted by chantra on November 6th, 2006

This entry is part 2 of 2 in the series How To Set up a repository cache with apt-cacher

3. Setting up the Clients and Server sources.list

Now it is time to set up the client hosts apt source list files: /etc/apt/sources.list. It make sense to use the repository cache on the server too, as that way, any updates made by the server will fill up the cache.

Here is the original /etc/apt/sources.list:

#debuntu repository
deb http://repository.debuntu.org edgy multiverse
deb-src http://repository.debuntu.org edgy multiverse
#ubuntu main repository
deb http://archive.ubuntu.com/ubuntu/ edgy main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ edgy main restricted universe multiverse
#ubuntu updates repository
deb http://archive.ubuntu.com/ubuntu/ edgy-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ edgy-updates main restricted universe multiverse
#ubuntu security updates repository
deb http://security.ubuntu.com/ubuntu edgy-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu edgy-security main restricted universe multiverse

In order to use our cache repository, those entries need to be changed to:

#debuntu repository
deb http://repository-cache:3142/debuntu edgy multiverse
deb-src http://repository-cache:3142/debuntu edgy multiverse
#ubuntu main repository
deb http://repository-cache:3142/ubuntu edgy main restricted universe multiverse
deb-src http://repository-cache:3142/ubuntu edgy main restricted universe multiverse
#ubuntu updates repository
deb http://repository-cache:3142/ubuntu-updates edgy-updates main restricted universe multiverse
deb-src http://repository-cache:3142/ubuntu-updates edgy-updates main restricted universe multiverse
#ubuntu security updates repository
deb http://repository-cache:3142/ubuntu-security edgy-security main restricted universe multiverse
deb-src http://repository-cache:3142/ubuntu-security edgy-security main restricted universe multiverse

Cool, now, every host should be able to retrieve the .deb packages from our repository cache once:

$sudo apt-get update

has been ran on every host.

4. Importing existing package from /var/cache/apt/archives/ to apt-cacher repository

It might happen that your server already got a whole lot of packages cached in its local repository: /var/cache/apt/archives/. apt-cacher offers a tool to import those files to apt-cacher repository.

There is a whole lot of usefull script that can be found in /usr/share/apt-cacher/. The one we are interested in here is apt-cacher-import.pl. To import deb files from /var/cache/apt/archives to apt-cacher repository run:

$sudo /usr/share/apt-cacher/apt-cacher-import.pl /var/cache/apt/archives

This must be run as user root or .deb files might not be copied to the cache repository

Now, the directory /var/cache/apt-cacher/packages/ should be filled up with a whole bunch of packages.

5. Getting report usage of your repository cache

If you left the directive generate_reports set to 1, apt-cacher will generate report on the usage of the cache every day.

You will be able to access it at the address: http://repository-cache:3142/report

.

If you need to regenerate the report, run: $sudo /usr/share/apt-cacher/apt-cacher-report.pl

6. Conclusion

apt-cacher is an easy and efficient package which will save you both time and bandwidth when using multiple machines with the same distribution like it could happen in a home network or in at a company.

Series Navigation<< How To Set up a repository cache with apt-cacher

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>