Wednesday, March 14, 2012

Lusca feat Debian

1. Debian 6 'Squeeze' (sudah terinstal)
2. LUSCA_HEAD-r14809.tar.gz (http://lusca-cache.googlecode.com/files/LUSCA_HEAD-r14809.tar.gz)
3. Patch Lusca (http://netvermore.googlecode.com/files/lusca_patch.tar.gz)
4. Contoh file konfigurasi squid.conf (http://netvermore.googlecode.com/files/squid.conf)
   dan file storeurl.pl (http://netvermore.googlecode.com/files/storeurl.pl)
   
$ sudo su
# apt-get install gcc build-essential sharutils libzip-dev automake

pastikan paket di atas terinstal semuanya, kemudian

# wget http://lusca-cache.googlecode.com/files/LUSCA_HEAD-r14809.tar.gz
# wget http://netvermore.googlecode.com/files/lusca_patch.tar.gz
# tar -xzvf LUSCA_HEAD-r14809.tar.gz

lakukan patch pada Lusca, asumsi saya kita download lusca di /home/user-masing2/LUSCA_HEAD-r14809/, user saya 'nvm'.

# tar -xzvf lusca_patch.tar.gz
# cd patch
# cp 3xx\ loop.diff ignore-must-revalidate.diff keblux-lusca-gzip.patch luscaVaryrR14697.diff /home/nvm/LUSCA_HEAD-r14809/
# cd /home/nvm/LUSCA_HEAD-r14809/
# patch -p0 < luscaVaryrR14697.diff
# patch -p0 < 3xx\ loop.diff
# patch -p0 < ignore-must-revalidate.diff
# patch -p2 < keblux-lusca-gzip.patch
# ./bootstrap.sh

anda bisa ketikkan perintah ./configure --help untuk melihat opsi-opsi yang ada.

# ./configure --prefix=/usr --exec_prefix=/usr --bindir=/usr/sbin --sbindir=/usr/sbin --libexecdir=/usr/lib/squid --sysconfdir=/etc/squid \
--localstatedir=/var/spool/squid --datadir=/usr/share/squid --enable-http-gzip --enable-async-io=24 --with-aufs-threads=24 \
--with-pthreads --enable-storeio=aufs --enable-linux-netfilter --enable-arp-acl --enable-epoll --enable-removal-policies=heap \
--with-aio --with-dl --enable-snmp --enable-delay-pools --enable-htcp --enable-cache-digests --disable-unlinkd --enable-large-cache-files \
--with-large-files --enable-err-languages=English --enable-default-err-language=English --with-maxfd=65536 --enable-gnuregex

note: apabila terjadi error, coba cek apakah paket gcc, build-essential, sharutils, libzip-dev, automake sudah terinstal dg baik atau belum.

# make && make install

tunggu sampai install selesai, jika ingin menghapus file-file sisa instalasi gunakan make install clean
sekarang kita download squid.conf dan storeurl.pl ke /etc/squid/

# cd /etc/squid
# mv squid.conf squid.conf.asli
# wget http://netvermore.googlecode.com/files/squid.conf
# nano squid.conf

sesuaikan dengan konfigurasi network anda, jika sudah simpan dan keluar dari editor nano.

# wget http://netvermore.googlecode.com/files/storeurl.pl
# nano storeurl.pl

lihat pada baris pertama terdapat #!/usr/local/bin/perl sesuaikan dengan path perl anda, di debian biasanya

#!/usr/bin/perl atau bisa juga dengan versi #!/usr/local/bin/perl5.12.4

note: untuk mengecek path-nya di debian, masuk ke /usr/bin
      # cd /usr/bin
      # ls -l | grep perl

jika sudah selesai konfigurasi, kita cek apakah file-file yang dibutuhkan squid sudah ada apa belum seperti di /var/log/squid/ ada cache.log, access.log dan store.log.
jika belum, maka buat secara manual:

# cd /var/log
# mkdir squid
# cd squid
# touch access.log cache.log store.log

jika pengecekan selesai, kita sudah siap menjalankan proxy kita, tapi sebelumnya kita buat swap directory dulu di direktori cache dengan perintah:

# squid -z

jika sudah, kita jalankan Lusca:

# squid -d 1 -N
2011/12/30 13:18:41| Starting Squid Cache version LUSCA_HEAD-r14809 for i686-pc-linux-gnu...
2011/12/30 13:18:41| Process ID 1930
2011/12/30 13:18:41| NOTICE: Could not increase the number of filedescriptors
2011/12/30 13:18:41| With 1024 file descriptors available
2011/12/30 13:18:41| Using epoll for the IO loop
2011/12/30 13:18:41| Performing DNS Tests...
2011/12/30 13:18:41| Successful DNS name lookup tests...
2011/12/30 13:18:41| Adding nameserver 114.141.57.2 from squid.conf
2011/12/30 13:18:41| helperOpenServers: Starting 24 'storeurl.pl' processes
2011/12/30 13:18:41| logfileOpen: opening log /var/log/squid/access.log
2011/12/30 13:18:41| Swap maxSize 512000000 + 8192 KB, estimated 10240163 objects
2011/12/30 13:18:41| Target number of buckets: 512008
2011/12/30 13:18:41| Using 524288 Store buckets
2011/12/30 13:18:41| Max Mem  size: 8192 KB
2011/12/30 13:18:41| Max Swap size: 512000000 KB
2011/12/30 13:18:41| Local cache digest enabled; rebuild/rewrite every 3600/3600 sec
2011/12/30 13:18:41| logfileOpen: opening log /var/log/squid/store.log
2011/12/30 13:18:41| AUFS: /cache: log '/cache/swap.state' opened on FD 35
2011/12/30 13:18:41| AUFS: /cache: tmp log /cache/swap.state.new opened on FD 35
2011/12/30 13:18:41| Rebuilding storage in /cache (DIRTY)
2011/12/30 13:18:41| Using Least Load store dir selection
2011/12/30 13:18:41| Current Directory is /home/support
2011/12/30 13:18:41| Loaded Icons.
2011/12/30 13:18:41| Accepting transparently proxied HTTP connections at 0.0.0.0, port 3128, FD 37.
2011/12/30 13:18:41| Accepting HTCP messages on port 4827, FD 38.
2011/12/30 13:18:41| Accepting SNMP messages on port 3401, FD 39.
2011/12/30 13:18:41| WCCP Disabled.
2011/12/30 13:18:41| Ready to serve requests.

langkah terakhir adalah menempatkan service di startup agar lusca otomatis jalan setiap kali booting

# nano /etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

ulimit -n 5000 
/usr/sbin/squid -sYD &

exit 0

note: ulimit -n xxxx adalah untuk menyetting besar File Descriptors, semakin besar angkanya, maka akan memakan resource memory semakin besar pula.
      untuk melihat keterangan mengenai file descriptors akan dijelaskan dibawah.

untuk melihat keterangan detail tentang Lusca/Squid, kita install dulu paket squidclient:

# apt-get install squidclient
# squidclient mgr:info