10

I have more than 500 systems running ubuntu 10.04, ubuntu 10.10 and ubuntu 11.04. It is difficult for us to install new packages to these machines from internet, because of the high bandwidth usage. I am planning to set up an apt-cacher server, such that it should install packages from a local machine, instead of installing packages from the internet. Can anyone give me a neat solution please? Thanks in advance.

Error in server configuration:

root@karthick:~# sudo /usr/share/apt-cacher/apt-cacher-import.pl /var/cache/apt/archives
Importing: acl_2.2.49-3_i386.deb
Failed to rename acl_2.2.49-3_i386.deb. Try read-only (-r) or symlink (-s) options. at /usr/share/apt-cacher/apt-cacher-import.pl line 154.

Error in client on installing packages enter image description here

Can anyone sort out pls?

karthick87
  • 81,947

3 Answers3

10

From Apt-Cacher-Server:

Server side configuration.

  1. Install apt-cacher and apache2 webserver on the system that you want it to host: sudo apt-get install apt-cacher apache2. Remove apache is you already have that running.
  2. Enable apt-cacher: sudo gedit /etc/default/apt-cacher.Change autostart to 1
  3. If apache is already installed before installing apt-cacher: sudo invoke-rc.d apache2 restart. You should be able to access http://server:3142 now.
  4. /etc/apt-cacher/apt-cacher.conf contains all the settings. Adjust them to your needs.
  5. Import local cache: sudo /usr/share/apt-cacher/apt-cacher-import.pl /var/cache/apt/archives
  6. Mount the installer CD: sudo mount -o loop /home/username_or_other_path/ubuntu-9.10-rc-alternate-i386.iso /media/cdrom0 and import the CD cache: sudo /usr/share/apt-cacher/apt-cacher-import.pl -R -r /media/cdrom0.

Client side configuration:

  1. Sources.list: change all the URLs to point to your servers URL. (ie. deb http://apt-cacher-server:3142/archive.ubuntu.com/ubuntu/) (change 1 client and if it works copy it over to all other systems)

2a. Use as a proxy to APT: Static configuration. In a terminal, type:
sudo nano /etc/apt/apt.conf.d/01proxy
Add: Acquire::http::Proxy "http://<IP address or hostname of the apt-cacher server>:3142";

2b. Use as a proxy to APT: Roaming configuration: see the link at the top for setup and script.

untested by myself but someone at work used this page to set it up for ourself.

edit: About the error: apparently Perl’s rename function can’t move files across devices, and that’s how the imports and cache laid on the disk.

Options: 1. use the -s parameter (only creates symlinks). 2. Manually move the files onto the same device before importing.

Rinzwind
  • 299,756
  • Thanks a lot for the brief explanation. As i said already i have ubuntu 10.04,10.10 and natty. So if i install some packages in natty it should install packages from the local natty source and if i install some packages in ubuntu 10.04 it should install packages from the local 10.04 source. Will it happen like that? Or i want to setup 3 apt-cacher server? like one for ubuntu 10.04 and another for 10.10 and the last one for natty ? – karthick87 Jun 02 '11 at 09:22
  • Don't know... we use it for 1 system and 1 only (all clients follow the same upgrade path so all are on Maverick at the moment) But... packages from different versions also have different names and the sources list of the clients(!) has the version name. I think it should work with 1 apt-server. – Rinzwind Jun 02 '11 at 09:53
  • What version of ubuntu you use for apt-cacher server ? – karthick87 Jun 02 '11 at 10:00
  • We use Maverick. – Rinzwind Jun 02 '11 at 10:05
  • Ubuntu - 10.10 Server edition right ? – karthick87 Jun 02 '11 at 10:09
  • We use the desktop edtion but it does not really matter wich you use: it basically is set around apache so what OS it relies upon should not really matter. – Rinzwind Jun 02 '11 at 10:13
  • How to set cd cache with latest updates? – karthick87 Jun 05 '11 at 15:00
  • I do not get your q. Sorry... the cd cache is taking so you do not need to download these files from the web (it's alot quicker this way). Updates will happen automatically when you update your system (???) – Rinzwind Jun 05 '11 at 15:25
  • Fine, thanks a lot. Can you please provide the link for downloading the CD cache for the ubuntu version 10.10 ? – karthick87 Jun 06 '11 at 13:51
  • This should cache the cd contents (for any release) sudo /usr/share/apt-cacher/apt-cacher-import.pl -R -r /media/cdrom0 (it's only to not have to download the whole cd content from the ubuntu servers) – Rinzwind Jun 06 '11 at 13:53
  • I am getting an error on entering a particular command. Pls see the updates in my question. – karthick87 Jun 08 '11 at 14:41
  • I found the same error mentioned here: http://mummila.net/nuudelisoppa/2009/08/15/apt-cacher-import-pl-fails-to-rename-move-deb-files-during-import/ and put it in the answer! – Rinzwind Jun 08 '11 at 14:54
  • Which files i have to move and to which location? – karthick87 Jun 08 '11 at 15:06
4

I never got any of those apt-cachers working right, so I asked Michael Vogt if we could ship an easy to use squid configuration for exactly this, and squid-deb-proxy was born.

It's very easy to set up and requires no config on the client part apart from installing the client package.

Instructions for how to use it are here:

Jorge Castro
  • 71,754
  • I want cross check the setup, to findout whether the setup is working or not. How do i do that? – karthick87 Jun 05 '11 at 14:59
  • +1. Definitely along the lines of zero-configuration. squid-deb-proxy is fantastic and for the average user, should be preferred over apt-cacher and friends. – Ehtesh Choudhury Feb 05 '14 at 15:47
1

I think a transparent proxy, like Squid would do the job easily.

Iradrian
  • 1,318