Debian/Ubuntu: Menghemat bandwidth dengan apt-cacher

May 19 | Posted by Muhammad Yusuf E. | Linux Software Tags: , , ,

Anda memakai beberapa PC dengan OS Debian/Ubuntu dalam satu network? Kalau iya, maka anda perlu mengetahui apa itu apt-cacher untuk menghemat bandwidth anda.
Dengan apt-cacher, maka update paket dari OS dapat dilakukan satu pc, sedangkan PC yang lain dapat memakai cache update. Dengan setting ini PC yang lain dapat menggunakan cache PC yang pertama untuk melakukan update, sehingga tidak perlu lagi harus update dengan memakai bindwidth networking.

Installing

Untuk menginstall apt-cacher anda harus melakukannya dengan user root.
Cukup dengan menjalankan perintah seperti di bawah ini.

sudo aptitude install apt-cacher

Configuring

File configurasi ada di /etc/apt-cacher/apt-cacher.conf, silakan cek dan ganti parameter yang dirasakan perlu.

# cache_dir is used to set the location of the local cache. This can
# become quite large, so make sure it is somewhere with plenty of space.
cache_dir=/var/cache/apt-cacher

# worried about unauthorised machines fetching packages through it, you can
# specify a list of IPv4 addresses which are allowed to use it and another
# list of IPv4 addresses which aren't.
# Localhost (127.0.0.1) is always allowed. Other addresses must be matched
# by allowed_hosts and not by denied_hosts to be permitted to use the cache.
# Setting allowed_hosts to "*" means "allow all".
# Otherwise the format is a comma-separated list containing addresses,
# optionally with masks (like 10.0.0.0/22), or ranges of addresses (two
# addresses separated by a hyphen, no masks, like '192.168.0.3-192.168.0.56').
allowed_hosts=10.1.1.0/24
denied_hosts=

# Apt-cacher can generate usage reports every 24 hours if you set this
# directive to 1. You can view the reports in a web browser by pointing
# to your cache machine with '/apt-cacher/report' on the end, like this:
# http://yourcache.example.com/apt-cacher/report
# Generating reports is very fast even with many thousands of logfile
# lines, so you can safely turn this on without creating much
# additional system load.
generate_reports=1

# Apt-cacher can clean up its cache directory every 24 hours if you set
# this directive to 1. Cleaning the cache can take some time to run
# (generally in the order of a few minutes) and removes all package
# files that are not mentioned in any existing 'Packages' lists. This
# has the effect of deleting packages that have been superseded by an
# updated 'Packages' list.
clean_cache=1

# apt-cacher can use different methods to decide whether package lists need to
# be updated,
# A) looking at the age of the cached files
# B) getting HTTP header from server and comparing that with cached data. This
# method is more reliable and avoids desynchronisation of data and index files
# but needs to transfer few bytes from the server every time somebody requests
# the files ("apt-get update")
# Set the following value to the maximum age (in hours) for method A or to 0
# for method B
expire_hours=0

Hati-hati bahwa direktori untuk menyimpan cache, cache_dir harus mempunyai space yang cukup.
Untuk masalah security jangan lupa perhatikan setting di bagian allowed_hosts dan denied_hosts.

Start the server
Edit /etc/default/apt-cacher dan ubah nilai AUTOSTART ke 1, sepeti berikut ini.

# apt-cacher startup configuration file

# IMPORTANT: check the apt-cacher.conf file before using apt-cacher as daemon.

# set to 1 to start the daemon at boot time
AUTOSTART=1

# extra settings to override the ones in apt-cacher.conf
# EXTRAOPT=" daemon_port=3142 limit=30 "

Jalankan server anda seperti berikut ini.

sudo /etc/init.d/apt-cacher restart

Kemudian check dengan browser anda ke alamat berikut.

http://127.0.0.1:3142/apt-cacher/

Configure pc anda
Agar pc anda memakai cache ini, edit file /etc/apt/apt.conf, masukkan nilai seperti berikut

Acquire::http::Proxy "http://127.0.0.1:3142/apt-cacher/";

127.0.0.1 adalah ip address anda.
Selamat mencoba!!!

Tags: , , ,

3 Responses to “Debian/Ubuntu: Menghemat bandwidth dengan apt-cacher”

  1. Jonet says:

    Terima kasih atas tulisannya. Saya mencari tool ini sudah sejak lama..thanks.

  2. [...] Dengan apt-cacher, maka update paket dari OS dapat dilakukan satu pc, sedangkan PC yang lain dahttp://infokomtek.com/2008/05/19/debianubuntu-menghemat-bandwidth-dengan-apt-cacher/APA Citation FormatExamples of apa format for Citing Resources Print, Media, and Electronic … [...]

  3. rhara says:

    maaf saya mengambil sedikit artikelnya,,,,,,,,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

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