Load Balancing Dengan
Bonding Ethernet
Aris Wendy Sunyoto
aris_wendy@yahoo.com
Kebutuhan akan peningkatan performance koneksi suatu server di saat ini sudah tak dapat terelakkan lagi. Banyak teknologi yang digunakan untuk meningkatkan kualitas suatu koneksi. Taruh saja cisco dengan spaning tree nya, fault tolerance, load balancing dan sebagainya. Untuk teknologi terakhir ini penulis mencoba membahas dengan menggunakan ”bonding ethernet”. Beberapa perangkat yang dibutuhkan adalah :
1. Linux box : distro terserah…… dalam hal penulis menggunakan debian woody 3.0
2. Ethernet lebih dari 1, menurut om Donald Becker’s penulis code driver ethernet lebih baik menggunakan ethernet intel eepro100 dan 3com 3c59x
3. Bonding ethernet yang dapat anda download di
http://www.sourceforge.net/projects/bonding/
Untuk debian tinggal apt-get aja di cdrom masing masing
Load balancing pada ethernet adalah teknik untuk meningkatkan kualitas koneksi dengan jalan membagi beban (traffic) ke setiap masing masing ethernet dengan jumlah yang sama. Logikanya kita lebih memilih ethernet 100 Mbps berjumlah 10 buah dibanding 1 Gigabit full duplex. Salah satu alasan yang masuk akal adalah bootle neck.
—— eth0 ———- client
—— eth1 ———- client
—— eth2 ———- client
Untuk alasan tersebut load balancing diterapakan. Sekarang timbul pertanyaan ”Lho kalau beda ip dan network khan bisa diatasi mengapa harus dibuat teknik seperti itu ?” Good question…….but easy to answer after you read this article.
Kita nggak bisa membayangkan untuk membagi beban pada NIC (network Interface Card) anda dilakukan pembedaan IP. Teknik ini sangat sulit dilakukan mengingat aplikasi yang digunakana adalah client server. Tentu anda juga memikirkan coding untuk membuat aplikasi tersebut yang setiap usernya didefinisikan berbeda satu dengan yang lain. Ok guys……Let’s start on it…………!!!
Follow it !!!
1. Install paket bonding (ifenslave) dengan menggunakan perintah
aris-deb# apt-get install ifenslave
Reading Package Lists…
Building Dependency Tree…
The following NEW packages will be installed:
ifenslave
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/8412B of archives. After unpacking 73.7kB will be used.
Media Change: Please insert the disc labeled ‘Debian GNU/Linux 3.0 r0 _Woody_ - Official i386 Binary-7 (20020718)’ in the drive ‘/cdrom/’ and press enter
Selecting previously deselected package ifenslave.
(Reading database … 6991 files and directories currently installed.)
Unpacking ifenslave (from …/ifenslave_0.07-1_i386.deb) …
Setting up ifenslave (0.07-1) …
Jika anda menginginkan instal dari source gunakan perintah :
gcc -Wall -Wstrict-prototypes -O -I/usr/src/linux/include ifenslave.c -o ifenslave
2. Aktifkan masing masing ethernet yang anda punyai
aris-deb# modprobe 3c59x
3. Aktifkan ethernet bonding anda
aris-deb# modprobe bonding mode=0 miimon=200 updelay=200 downdelay=200
Keterangan mode :
mode
Specifies one of four bonding policies. The default is
round-robin (balance-rr). Possible values are (you can use either the
text or numeric option):
balance-rr or 0
Round-robin policy: Transmit in a sequential order
from the first available slave through the last. This
mode provides load balancing and fault tolerance.
active-backup or 1
Active-backup policy: Only one slave in the bond is
active. A different slave becomes active if, and only
if, the active slave fails. The bond’s MAC address is
externally visible on only one port (network adapter)
to avoid confusing the switch. This mode provides
fault tolerance.
balance-xor or 2
XOR policy: Transmit based on [(source MAC address
XOR’d with destination MAC address) modula slave
count]. This selects the same slave for each
destination MAC address. This mode provides load
balancing and fault tolerance.
broadcast or 3
Broadcast policy: transmits everything on all slave
interfaces. This mode provides fault tolerance.
miimon
Specifies the frequency in milli-seconds that MII link monitoring will
occur. A value of zero disables MII link monitoring. A value of
100 is a good starting point. See High Availability section for
additional information. The default value is 0.
downdelay
Specifies the delay time in milli-seconds to disable a link after a
link failure has been detected. This should be a multiple of miimon
value, otherwise the value will be rounded. The default value is 0.
updelay
Specifies the delay time in milli-seconds to enable a link after a
link up status has been detected. This should be a multiple of miimon
value, otherwise the value will be rounded. The default value is 0.
arp_interval
Specifies the ARP monitoring frequency in milli-seconds.
If ARP monitoring is used in a load-balancing mode (mode 0 or 2), the
switch should be configured in a mode that evenly distributes packets
across all links - such as round-robin. If the switch is configured to
distribute the packets in an XOR fashion, all replies from the ARP
targets will be received on the same link which could cause the other
team members to fail. ARP monitoring should not be used in conjunction
with miimon. A value of 0 disables ARP monitoring. The default value
is 0.
arp_ip_target
Specifies the ip address to use when arp_interval is > 0. This is the
target of the ARP request sent to determine the health of the link to
the target. Specify this value in ddd.ddd.ddd.ddd format.
primary
Specifies the preferred primary network interface in a given team. The
preferred primary interface is designated with a string value equal to
eth0, eth1, etc. and is valid in active-backup mode only. The role of
the primary adapter is to transmit and receive all data as long as the
link connection is up. If the preferred primary adapter should fail,
then a secondary adapter would take over as the new primary. The
preferred primary adapter would then take over as soon as it’s status
changes back to favorable. This parameter is beneficial when one
adapter performs better than one or more of the other adapters in a
given team, i.e. Gigabit adapter versus a Fast Ethernet adapter or an
adapter with a new chip set verses one with an older chip set.
max_bonds
Specifies the number of bonding devices to create for this
instance of the bonding driver. E.g., if max_bonds is 3, and
the bonding driver is not already loaded, then bond0, bond1
and bond2 will be created. When max_bonds is used, all bonds
controlled by that instance will have the same parameters.
The default value is 1.
multicast
Option specifying the mode of operation for multicast support.
Possible values are:
disabled or 0
Disabled (no multicast support)
active or 1
Enabled on active slave only, useful in active-backup mode
all or 2
Enabled on all slaves, this is the default
4. Konfigurasi IP dengan mengedit file /etc/network/interfaces
# /etc/network/interfaces — configuration file for ifup(8), ifdown(8)
# The loopback interface
auto lo
iface lo inet loopback
auto bond0
iface bond0 inet static
address 192.168.22.214
broadcast 192.168.22.255
network 192.168.22.22.0
netmask 255.255.255.0
auto eth0
iface eth0 inet static
address 192.168.22.214
broadcast 192.168.22.255
network 192.168.22.22.0
netmask 255.255.255.0
up /usr/sbin/ifenslave bond0 eth0
auto eth1
iface eth1 inet static
address 192.168.22.214
broadcast 192.168.22.255
network 192.168.22.22.0
netmask 255.255.255.0
up /usr/sbin/ifenslave bond0 eth1
auto eth2
iface eth2 inet static
address 192.168.22.214
broadcast 192.168.22.255
network 192.168.22.22.0
netmask 255.255.255.0
up /usr/sbin/ifenslave bond0 eth2
5. Restart serice dan cek ulang konfigurasi
aris-deb# /etc/init.d/networking restart
aris-deb# ifconfig
6. Tambahkan bonding mode=0 miimon=100 updelay=200 downdelay=200 pada /etc/modules agar module ini dapat diload saat computer start.
7. Lihat ulang apakah bonding sudah berjalan dengan baik apa tidak..
Bonding Mode: load balancing
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200
Slave Interface: eth2
MII Status: up
Link Failure Count: 0
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
8. Testing dengan ping
64 bytes from 192.168.22.2: icmp_seq=16 ttl=128 time=0.1 ms
64 bytes from 192.168.22.2: icmp_seq=19 ttl=128 time=0.1 ms
64 bytes from 192.168.22.2: icmp_seq=22 ttl=128 time=0.1 ms
64 bytes from 192.168.22.2: icmp_seq=25 ttl=128 time=0.1 ms
icmp sequence naik 3 step menunjukkan jumlah ethernet yang bekerja. Jadi gambar diatas menunjukkan output dari 1 ethernet.
9. Lihat juga output pada iptraf berikut ini
Output diatas menunjukkan bahwa beban pada tiap tiap ethernet sama (balance). Sehingga sangat meningkatkan performance network anda.
File download dapat anda download disini
Ucapan terima kasih :
1. Om Donald Becker atas codingnya http://www.scyld.com/network/
2. Team bonding http://www.sourceforge.net/projects/bonding/