Page 1 of 5 123 ... LastLast
Results 1 to 10 of 41

Thread: How To Install Apt-Cacher-NG in Ubuntu Linux

  1. #1
    Join Date
    Aug 2006
    Location
    Europe
    Beans
    Hidden!
    Distro
    Ubuntu 10.04 Lucid Lynx

    How To Install Apt-Cacher-NG in Ubuntu Linux

    The following procedure describes How To install the Apt-Cacher-NG package in Ubuntu Linux.

    (published at: http://ubuntuforums.org/showthread.php?t=981085)

    Apt-Cacher-ng <http://www.unix-ag.uni-kl.de/~bloch/acng/> is a software package that keeps a cache on the disk, of Debian Packages and Release files.
    When an apt-get issues a request for a file, Apt-Cacher intercepts it and if the file is already in the cache it serves it to the client immediately, otherwise it fetches the file from the Internet, saves it on disk, and then serves it to the client. This means that each package needs to be downloaded only once, in order to let several Debian machines to use it afterwards.

    Apt-Cacher-NG does not require an interpreter, nor a web server.
    It does not: fork after server startup; create flag files; flock() files.
    It uses native system functions (mmap, sendfile) to operate with few overhead.

    1. Install Apt-Cacher-NG on the server machine
    1.1. Download & Install from Ubuntu pool
    sudo apt-get install apt-cacher-ng

    1.2 RECOMMENDED: build & install from latest sources
    sudo apt-get install libbz2-dev libfuse-dev # install support apps

    # goto <http://ftp.debian.org/debian/pool/main/a/apt-cacher-ng/?C=M;O=D> and download the newest source:

    cd $(mktemp -d) ; # create a temp dir and cd to it
    wget http://ftp.debian.org/debian/pool/ma....6.orig.tar.gz
    # get the sources from the debian/ubuntu repositories
    apt-get source apt-cacher-ng
    cd $(ls -d apt-cacher-ng-*/)

    # update package info to new version
    (export DEBFULLNAME='dummy';export DEBEMAIL='dummy <dummy@example.com>';uupdate --upstream-version 0.4.6 ../apt-cacher-ng_0.4.6.orig.tar.gz)
    cd ../"$(dpkg-parsechangelog | sed -n 's/^Source: //p')-0.4.6"

    # customize maintainer data
    grep '^Maintainer\|^Uploaders\|XSBC-Original-Maintainer' debian/control
    sed -i '/^Maintainer/s/: .*/: dummy <dummy@example.com>/;/^Uploaders/s/: .*/: dummy <dummy@example.com>/;/XSBC-Original-Maintainer/d' debian/control;

    # adjust runlevel arguments
    sed -i 's/2 3 5/2 3 4 5/;s/0 6/0 1 6/' debian/apt-cacher-ng/etc/init.d/apt-cacher-ng # grep '2 3\|0 ' debian/apt-cacher-ng/etc/init.d/apt-cacher-ng
    sed -i 's/2 3 5/2 3 4 5/;s/0 6/0 1 6/' debian/apt-cacher-ng.init # grep '2 3\|0 ' debian/apt-cacher-ng.init

    # build the new package
    (export DEBFULLNAME='dummy';export DEBEMAIL='dummy@example.com';debuild -i -us -uc);

    cd .. ; cp -avf apt-cacher-ng*deb /home/ftp/it-sw-bin/
    sudo apt-get purge libbz2-dev libfuse-dev # remove support apps

    sudo dpkg -i apt-cacher-ng*deb && echo "apt-cacher-ng hold" | sudo dpkg --set-selections

    2. Configure (apply to server and each client machine)
    # search & replace 192.168.1.100 by the IP of the machine that will act as apt-cacher-ng server

    # enable proxy usage by apt-get, aptitude, etc.
    echo 'Acquire::http { Proxy "http://192.168.1.100:3142"; };' | sudo tee /etc/apt/apt.conf.d/01apt-cacher-ng-proxy

    # enable proxy usage by Synaptic
    sudo grep --color -i 'proxy' /root/.synaptic/synaptic.conf || sudo nano /root/.synaptic/synaptic.conf

    # ...and overwrite the last line }; with:
    useProxy "1";
    httpProxy "192.168.1.100";
    httpProxyPort "3142";
    ftpProxy "192.168.1.100";
    ftpProxyPort "3142";
    noProxy "";
    };
    sudo grep --color -i 'proxy' /root/.synaptic/synaptic.conf

    # ...or enable proxy using the Synaptic GUI:
    a) In Synaptic go to "Settings->Preferences->Network"
    b) click "Manual Proxy Configuration"
    c) enter:
    HTTP Proxy: 192.168.1.100 3142
    FTP Proxy: 192.168.1.100 3142
    Click OK
    Click Reload

    sudo apt-get update # now update the apt-get system

    3. Import local .deb files
    test -x /var/cache/apt-cacher-ng/_import || sudo mkdir -p -m 2755 /var/cache/apt-cacher-ng/_import
    sudo mv -uf /var/cache/apt/archives/*.deb /var/cache/apt-cacher-ng/_import/

    sudo chown -R apt-cacher-ng.apt-cacher-ng /var/cache/apt-cacher-ng/_import

    # start import at: <http://192.168.1.100:3142/acng-report.html?doImport=Start+Import#bottom>

    # cleanup and update apt cache index files
    sudo rm -fr \
    /var/cache/apt-cacher-ng/_import \
    /var/cache/apt/archives/*.deb \
    /var/cache/apt/*cache.bin \
    /var/lib/apt/lists/*Packages \
    /var/lib/apt/lists/*Sources
    sudo apt-get update

    4. To stop using the proxy
    # disable proxy usage
    sudo rm /etc/apt/apt.conf.d/01apt-cacher-ng-proxy # by apt-get
    sudo sed -i '/useProxy/s/1/0/' /root/.synaptic/synaptic.conf # by synaptic
    sudo /etc/init.d/apt-cacher-ng stop # stop
    sudo apt-get update
    # do click Reload in the Synaptic GUI

    # to completly remove the proxy from your system
    #sudo apt-get purge apt-cacher-ng
    #sudo rm -fr /var/cache/apt-cacher-ng

    5. Other: optional customizations
    # days before deleting unreferenced files
    grep ExTreshold /etc/apt-cacher-ng/acng.conf
    sudo sed -i 's/^ExTreshold:.*/ExTreshold: 15/' /etc/apt-cacher-ng/acng.conf

    6. Dashboard & manual
    # see the apt-cacher-ng dashboard at: <http://192.168.1.100:3142/acng-report.html>
    # see apt-cacher-ng User Manual at: (right click at the link and open with your browser): <file:///usr/share/doc/apt-cacher-ng/html/index.html>
    # Howtos: <http://www.unix-ag.uni-kl.de/~bloch/acng/html/howtos.html>
    ## -- END --
    Last edited by docplastic; February 16th, 2011 at 10:49 AM.

  2. #2
    Join Date
    Apr 2007
    Location
    Hasselt, Belgium
    Beans
    75
    Distro
    Ubuntu

    Re: How To Install Apt-Cacher-NG in Ubuntu Linux

    Thanks a lot! I've set it up on my slug (nslu2) running Debian Lenny. I've installed apt-cacher-ng from the repo's. It was already configured for Debian and Ubuntu, so from the server side this was plug 'n' play. For the clients I've used your settings.

    Apt-cacher-ng caches the repo's from the different versions of ubuntu quite nicely. It even nicely supports the different installs of intrepid in my home with different personal package archives (PPA, you know as in ppa.launchpad.net/*).

    Although the slug is a very slow machine (226 Mhz processor, 28 MB ram). I don't see any noticeable slowdown on htop.

    I'm very impressed with this package and it will come in very handy since I live in Belgium, which has fair adsl speeds, but with stupidly low bandwidth flat-rates. And that is a nasty combination.

    The only bad thing about apt-cacher-ng is that the documentation tries to make everything look very difficult, but thanks to your help, it's not.
    Last edited by my_key; January 6th, 2009 at 09:45 PM. Reason: typo
    Michael Cox

  3. #3
    Join Date
    May 2007
    Location
    Farnham, Surrey. UK
    Beans
    6
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: How To Install Apt-Cacher-NG in Ubuntu Linux

    Thanks, that was clear and easy to follow.

    And the cacher seems to be working fine

  4. #4
    Join Date
    Nov 2006
    Beans
    26
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: How To Install Apt-Cacher-NG in Ubuntu Linux

    what's the difference between apt-cacher and apt-cacher-ng? which one should i be installing?

  5. #5
    Join Date
    Aug 2006
    Location
    Europe
    Beans
    Hidden!
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How To Install Apt-Cacher-NG in Ubuntu Linux

    Quote Originally Posted by rozilla View Post
    what's the difference between apt-cacher and apt-cacher-ng? which one should i be installing?
    You should use apt-cacher-ng as it is newer, faster, needs less resources and is better maintained.

    M.

  6. #6
    Join Date
    May 2006
    Location
    gippsland
    Beans
    354

    Re: How To Install Apt-Cacher-NG in Ubuntu Linux

    echo 'Acquire::http { Proxy "http://localhost:3142"; };' | sudo tee /etc/apt/apt.conf.d/01proxy

    so you run this on the client machines and thats it?
    Last edited by koshari; April 30th, 2009 at 11:40 AM.

  7. #7
    Join Date
    Nov 2004
    Location
    Canada
    Beans
    345

    Re: How To Install Apt-Cacher-NG in Ubuntu Linux

    Why "download the latest version" ? At least make it clear that requires manual updates/upgrades! apt-cacher-ng is already packaged in Ubuntu.

    Step 3 also strikes me as unneeded.
    Fabián Rodríguez
    Ubuntu Quebec LoCo Team contact, UCP, UCI

  8. #8
    Join Date
    May 2009
    Beans
    3
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How To Install Apt-Cacher-NG in Ubuntu Linux

    Quote Originally Posted by magicfab View Post
    Why "download the latest version" ? At least make it clear that requires manual updates/upgrades! apt-cacher-ng is already packaged in Ubuntu.

    Step 3 also strikes me as unneeded.
    Code for Step One:

    apt-get install apt-cacher-ng
    Step 3 is necessary in order to reload the repository indexes. If you skip step 3, you will get an error when importing the local cache into apt-cacher-ng.

    If you don't wish to use the GUI tools, then substitute the following code for Step 3:

    sudo apt-get update
    Also... I've tested apt-cacher and apt-cacher-ng... I agree that apt-cacher-ng is SOOOO much faster!

    Enjoy!

  9. #9
    Join Date
    Nov 2008
    Beans
    75
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: How To Install Apt-Cacher-NG in Ubuntu Linux

    Is it neccessary to add a proxy to synaptic? I assumed it used the proxy that you specified in apt.conf.d?
    Dr. Robert Melamede: 'Marijuana is responsible for evolution itself.'

  10. #10
    Join Date
    Nov 2008
    Beans
    75
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Question Re: How To Install Apt-Cacher-NG in Ubuntu Linux

    Also has anyone tried this offline?

    I want to install a computer using net-boot-installer that fetches the pre-cached files from a server that is away from any sort of internet connection.
    Dr. Robert Melamede: 'Marijuana is responsible for evolution itself.'

Page 1 of 5 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •