Load Balancer
LVS(Linux Virtual Server) memungkinkan load balancing service-service network, seperti web ato email dan bekerja pada layer 4 switching. Terminologi: • Linux Director : Host dengan system operasi linux yang telah terinstall paket2 LVS(eg: ipvsadm) • Real Server : Host yang men-terminate connection(menjalankan service network, eg: web, proxy) • Virtual IP Address(VIP) : IP address yang di-assign ke Linux Director yang digunakan untuk meng-handle service. • Real IP address(RIP) : IP address dari Real Server.
LVS memiliki 3 jenis forwarding packet: Sama halnya dengan NAT. • Linux Director harus berada dalam satu network dengan Real Server. • Real Server dapat menggunakan OS apa saja. • Hampir tak ada konfigurasi tambahan di mesin Real Server, tapi gateway untuk Real Server di-set ke Linux Director. Contoh konfigurasi Linux Director: LVSNAT
echo 1 >/proc/sys/net/ipv4/ip_forward ifconfig eth0 152.118.24.129 netmask 255.255.255.0 ifconfig eth0:0 152.118.24.130 netmask 255.255.255.0 route add default gw 152.118.24.1 ipvsadm -A -t 152.118.24.130:8080 -s wrr ipvsadm -a -t 152.118.24.130:8080 -r 152.118.24.43:8080 -m -w 10 ipvsadm -a -t 152.118.24.130:8080 -r 152.118.24.10:8080 -m -w 20
LVSDR
Paket dari client akan langsung di-forward ke Real Server. • IP paket tidak dimodifikasi, jadi Real Server harus dikonfigurasi untuk meng-accept traffic dari VIP. • Reply paket dari Real Server akan langsung dikirim ke end user tanpa harus melewati Linux Director. Oleh karena itu, gateway untuk Real Server tidak harus Linux Director). • Linux Director harus berada dalam satu network dengan Real Server. • Perlu konfigurasi tambahan di mesin Real Server. Contoh konfigurasi Linux Director:
echo 1 >/proc/sys/net/ipv4/ip_forward ifconfig eth0 152.118.24.129 netmask 255.255.255.0 ifconfig eth0:0 152.118.24.130 netmask 255.255.255.0 route add default gw 152.118.24.1
ipvsadm -A -t 152.118.24.130:8080 -s wrr ipvsadm -a -t 152.118.24.130:8080 -r 152.118.24.43:8080 -g -w 10 ipvsadm -a -t 152.118.24.130:8080 -r 152.118.24.10:8080 -g -w 20
Contoh konfigurasi Real Server:
Tambahkan baris ini di file /etc/sysctl.conf(add this before network interface is up): net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2 net.ipv4.conf.lo.arp_ignore = 1 net.ipv4.conf.lo.arp_announce = 2 ifconfig lo:0 152.118.24.130 netmask 255.255.255.255
Memungkinkan paket yang ditujukan ke sebuah IP address, di-redirect ke IP address lain. • Mirip dengan LVS-DR. • Paket akan diforward ke Real Server menggunakan IP encapsulation. • Linux Director dapat berbeda network dengan Real Server. Contoh konfigurasi Linux Director:
echo 1 >/proc/sys/net/ipv4/ip_forward ifconfig eth0 152.118.24.129 netmask 255.255.255.0 ifconfig eth0:0 152.118.24.130 netmask 255.255.255.0 route add default gw 152.118.24.1
LVSTUN
ipvsadm -A -t 152.118.24.130:8080 -s wlc ipvsadm -a -t 152.118.24.130:8080 -r 152.118.148.218:8080 -i -w 20 ipvsadm -a -t 152.118.24.130:8080 -r 152.118.24.10:8080 -i -w 40
Contoh konfigurasi Real Server:
Tambahkan baris ini di file /etc/sysctl.conf(add this before network interface is up): net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2 net.ipv4.conf.tunl0.arp_ignore = 1 net.ipv4.conf.tunl0.arp_announce = 2 ifconfig tunl0 152.118.24.130 netmask 255.255.255.255
Implementasi di Jaringan UI
Untuk load balancer, sebaiknya menggunakan tipe forwarding yang ketiga, yaitu LVS-TUN, karena mesin proxy yang akan diload balancing berada di network yang berbeda(segmen 24 dan segmen 148). Router External UI Redirect semua request menuju port 8080(proxy) ke linux director:
iptables -I PREROUTING -t nat -p tcp -d 152.118.24.10 --dport 8080 -j DNAT --to-destination 152.118.24.130:8080 iptables -I PREROUTING -t nat -p tcp -d 152.118.148.116 --dport 8080 -j DNAT --to-destination 152.118.24.130:8080 iptables -I PREROUTING -t nat -p tcp -d 152.118.148.218 --dport 8080 -j DNAT --to-destination 152.118.24.130:8080
Linux Director
echo 1 >/proc/sys/net/ipv4/ip_forward ifconfig eth0 152.118.24.129 netmask 255.255.255.0 ifconfig eth0:0 152.118.24.130 netmask 255.255.255.0 route add default gw 152.118.24.1 ipvsadm -A -t 152.118.24.130:8080 -s wlc ipvsadm -a -t 152.118.24.130:8080 -r 152.118.148.116:8080 -i -w 20 ipvsadm -a -t 152.118.24.130:8080 -r 152.118.148.218:8080 -i -w 20 ipvsadm -a -t 152.118.24.130:8080 -r 152.118.24.10:8080 -i -w 40
Real Server(netcache.ui.edu, cumi.ui.edu, angle.ui.edu)
Tambahkan baris ini di file /etc/sysctl.conf(add this before network interface is up): net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2 net.ipv4.conf.tunl0.arp_ignore = 1 net.ipv4.conf.tunl0.arp_announce = 2 ifconfig tunl0 152.118.24.130 netmask 255.255.255.255
Why not using external router(152.118.24.1) as a linux director??? Why???why??? • Too many rules(iptables) in external router, may be the reply packet will be drop before reach to end user. • Read below message that I capture from the empu-nya LVS(klo gue gak salah nangkep seeh).
Notes:
• Sepertinya perlu gigabit untuk linux director(see picture). Klo nggak, interface Bonding yang dimesin
CUMI dicopot, terus “ditanamkan” ke mesin linux director.
• Dengan konfigurasi di atas, mungkin penggunaan bandwidth Indosat dan Telkom akan berimbang(I hope •
so, but I cannot guarantee :D). Trus, untuk menyisakan 5MB buat vicon, mungkin bisa menggunakan TCTraffic Control di router external. Klo ini bisa diimplementasi dan jalan, mungkin bandwidth tiap user bisa dinaikkan(..arghhh…sedang berkhayal..)
I’ve simmulated this configuration using vmware at my home and it works, but I’m not guarantee that It will works while we implement on UI network(we really2 dunno know until we try.. try it!!…try it!!).
Hope this works :D……CMIIW