Load Balancing adalah teknik untuk mendistribusikan beban trafik pada dua atau lebih jalur koneksi secara seimbang, agar trafik dapat berjalan optimal, memaksimalkan throughput, memperkecil waktu tanggap dan menghindari overload pada salah satu jalur koneksi.
Install HAProxy
root@haproxy# yum -y install haproxy
Konfigurasi HAProxy
root@haproxy# mv /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.org
root@haproxy# nano /etc/haproxy/haproxy.cfg
#Tambahkan script dibawah ini
global
# for logging section
log 127.0.0.1 local2 info
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
# max per-process number of connections
maxconn 256
# process' user and group
user haproxy
group haproxy
# makes the process fork into background
daemon
defaults
# running mode
mode http
# use global settings
log global
# get HTTP request log
option httplog
# timeout if backends do not reply
timeout connect 10s
# timeout on client side
timeout client 30s
# timeout on server side
timeout server 30s
# define frontend ( set any name for "http-in" section )
frontend http-in
# listen 80
bind *:80
# set default backend
default_backend backend_servers
# send X-Forwarded-For header
option forwardfor
# define backend
backend backend_servers
# balance with roundrobin
balance roundrobin
# define backend servers
server www01 192.168.67.137:80 check
server www02 192.168.67.33:80 check
root@haproxy# /etc/rc.d/init.d/haproxy start root@haproxy# chkconfig haproxy on
Configure Rsyslog to get logs for HAProxy
root@haproxy# vi /etc/rsyslog.conf #Edit Seperti Sintak dibawah ini #------------------------------------------ # line 13,14: uncomment, lne 15: add $ModLoad imudp $UDPServerRun 514 $AllowedSender UDP, 127.0.0.1 # line 42: change like follows *.info;mail.none;authpriv.none;cron.none,local2.none /var/log/messages local2.*
root@haproxy# /etc/rc.d/init.d/rsyslog restart
| Change httpd settings on Backends to logging X-Forwarded-For header Pastikan bahwa anda sudah menginstall httpd/apache server root@web1# vi /etc/httpd/conf/httpd.conf
##Tambahkan baris berikut ini
# line 497: change like follows
LogFormat "\"%{X-Forwarded-For}i\" %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
|
root@web1# /etc/rc.d/init.d/httpd restart
Lakukan httpd setting untuk web2, konfigurasi seperti di web1. Akses front server ( haproxy server) dari komputer client.
Untuk memastikan proses penjadwalan dari front server tekan F5 (refresh)

Tidak ada komentar:
Posting Komentar