Follow us on...
Follow us on G+ Follow us on Twitter Follow us on Facebook Watch us on YouTube
Register
Results 1 to 12 of 12
  1. mattnux's Avatar
    Status
    Offline
    Forum Guru Array
    Join Date
    Jun 2008
    Location
    jakarta
    Posts
    1,255
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    1 (100%)

    Jump to Comments

    load balancing webserver untuk high performance dan support failover (high availabil)

    11 Comments by mattnux Published on 04-02-2009 14:54
    High availability load balancer (support failover dan sesion) menggunakan HAProxy di debian base

    panduan kali ini akan menjelaskan cara membuat sebuah loadbalancer web menggunakan HAProxy, HAProxy adalah produk opensource yg mendukung keperluan loadbalancer dan failover webserver, banyak digunakan untuk keperluan reverseproxy di site2 yang trafik hariannya tinggi.

    bagaimana cara melihat apakah sebuah site(web) menggunakan loadbalancer atau tidak?mudah saja, misalkan maka ketik diterminal linux anda host -t a lalu enter
    hasilnya akan seperti ini
    is an alias for detik.com.
    detik.com has address 202.158.66.20
    detik.com has address 202.158.66.86
    detik.com has address 202.158.66.94
    detik.com has address 202.158.66.190
    detik.com has address 203.190.241.41
    detik.com has address 203.190.241.43
    detik.com has address 203.190.241.166

    di tulisan ini kita menggunakan simple diagram seperti ini
    * Load Balancer 1: lb1.example.com, IP address: 192.168.0.100
    * Load Balancer 2: lb2.example.com, IP address: 192.168.0.101
    * Web Server 1: http1.example.com, IP address: 192.168.0.102
    * Web Server 2: http2.example.com, IP address: 192.168.0.103
    * We also need a virtual IP address that floats between lb1 and lb2: 192.168.0.99

    Here's a little diagram that shows our setup:

    shared IP=192.168.0.99
    192.168.0.100 192.168.0.101 192.168.0.102 192.168.0.103
    -------+------------+--------------+-----------+----------
    | | | |
    +--+--+ +--+--+ +----+----+ +----+----+
    | lb1 | | lb2 | | http1 | | http2 |
    +-----+ +-----+ +---------+ +---------+
    haproxy haproxy 2 web servers (Apache)
    keepalived keepalived

    sebelum memulai ada baiknya anda pastikan aplikasi web yg anda pasang di webserver telah mendukung JSESSIONID
    ok langsung saja kita mulai Click here to enlarge

    di httpd1 dan http2
    1. persiapan di sisi web server, saya menggunakan apache2, anda sebaiknya menggunakan apache juga
    pada /etc/apache2/apache2.conf gantilah baris ini LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined dengan
    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

    lalu pastikan anda sudah mem paste baris ini dalam konfigurasi vhost anda di /etc/apache2/sites-available/default
    SetEnvIf Request_URI "^/check\.txt$" dontlog
    CustomLog /var/log/apache2/access.log combined env=!dontlog

    setelah itu restart atau reload ulang apache anda
    /etc/init.d/apache2 restart atau /etc/init.d/apache2 reload

    buat sebuah file check.txt
    touch /var/www/check.txt

    2. tahap ini kita akan menginstall HAProxy nya

    di lb1/lb2
    untuk anda pengguna ubuntu tinggal ketik
    sudo apt-get install haproxy

    3. tahap konfigurasi HAProxy

    di lb1/lb2

    setelah instalasi anda cek letak file konfigurasi haproxy dengan mengetik where haproxy
    di ubuntu biasanya ada di /etc/haproxy/haproxy.cfg , biasakan bakup aslinya
    cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg_asli
    cat /dev/null > /etc/haproxy/haproxy.cfg
    vim /etc/haproxy/haproxy.cfg lalu isi dengan baris2 seperti ini
    global
    log 127.0.0.1 local0
    log 127.0.0.1 local1 notice
    #log loghost local0 info
    maxconn 4096
    #debug
    #quiet
    user haproxy
    group haproxy

    defaults
    log global
    mode http
    option httplog
    option dontlognull
    retries 3
    redispatch
    maxconn 2000
    contimeout 5000
    clitimeout 50000
    srvtimeout 50000

    listen webfarm 192.168.0.99:80
    mode http
    stats enable
    stats auth someuser:somepassword
    balance roundrobin
    cookie JSESSIONID prefix
    option httpclose
    option forwardfor
    option httpchk HEAD /check.txt HTTP/1.0
    server webA 192.168.0.102:80 cookie A check
    server webB 192.168.0.103:80 cookie B check

    lalu set enbled=1 di /etc/default/haproxy seperti ini
    # Set ENABLED to 1 if you want the init script to start haproxy.
    ENABLED=1
    # Add extra flags here.
    #EXTRAOPTS="-de -m 16"

    selanjutnya kita membutuhkan sebuah jembatan antara haproxy dan web server agar bisa menyampaikan dan meminta webserver agar mau memonitoring request dari haproxy, kita butuh keepalived

    di lb1/lb2

    sudo apt-get install keepalived
    set juga /etc/sysctl.conf agar membolehkan sharing IP address dengan cara

    vim /etc/sysctl.conf

    tambahkan baris ini

    net.ipv4.ip_nonlocal_bind=1
    lalu ketik sysctl -p untuk me load ulang
    setelah haproxy selesai maka urusan selanjutnya adalah keepalivednya dong..hehehehe jangan bosen ya gan..

    di lb1

    vi /etc/keepalived/keepalived.conf
    vrrp_script chk_haproxy { # Requires keepalived-1.1.13
    script "killall -0 haproxy" # cheaper than pidof
    interval 2 # check every 2 seconds
    weight 2 # add 2 points of prio if OK
    }

    vrrp_instance VI_1 {
    interface eth0
    state MASTER
    virtual_router_id 51
    priority 101 # 101 on master, 100 on backup
    virtual_ipaddress {
    192.168.0.99
    }
    track_script {
    chk_haproxy
    }
    }

    maksud dari baris baris diatas adal kita ingin menggunakan LB1 agar menjadi yg aktif atau bahasa lainnya sebagai master Click here to enlarge

    jalankan service keepalived dengan cara biasa
    /etc/init.d/keepalived start

    ip addr sh eth0

    di lb2
    vim /etc/keepalived/keepalived.conf

    vrrp_script chk_haproxy { # Requires keepalived-1.1.13
    script "killall -0 haproxy" # cheaper than pidof
    interval 2 # check every 2 seconds
    weight 2 # add 2 points of prio if OK
    }

    vrrp_instance VI_1 {
    interface eth0
    state MASTER
    virtual_router_id 51
    priority 100 # 101 on master, 100 on backup
    virtual_ipaddress {
    192.168.0.99
    }
    track_script {
    chk_haproxy
    }
    }

    /etc/init.d/keepalived start

    ketik
    ip addr sh eth0
    seharusnya muncul seperti ini
    lb2:~# ip addr sh eth0
    2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:0c:29:e0:78:92 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.101/24 brd 192.168.0.255 scope global eth0
    inet6 fe80::20c:29ff:fee0:7892/64 scope link
    valid_lft forever preferred_lft forever
    lb2:~#


    tahap selanjutnya adalah di

    lb1/lb2

    /etc/init.d/haproxy start

    tahap selanjutnya adalah testing
    cobalah request ke 192.168.0.99 lalu anda perhatikan di loadbalancer2 dengan cara ketik
    ip addr sh eth0
    namun ada baiknya lb1 anda matikan dulu Click here to enlarge
    ini sekaligus membuktikan jika failovernya sudah bekerja bersama loadblancernya

    loadbalancing disini adalah untuk membagi beban web server, sedangkan untuk failovernya menggunakan keepalived

    ditulis tgl 3 feb 2009, untuk kerjaan kantor :P diposting di forummikrotik.com untuk sharing aza..
    salam
    mattnux

  2. The Following 12 Users Say Thank You to mattnux For This Useful Post:

    + Show/Hide list of the thanked


  3. Total Comments 11

    Comments

  4. #2
    Status
    Offline
    [a]
    [a]'s Avatar
    Administrator
    Join Date
    Jun 2007
    Location
    Jakarta, Indonesia, Indonesia
    Posts
    1,729
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    1 (100%)
    Thanks for the articles....

    Nice sharing, bro...Click here to enlarge

  5. #3
    Status
    Offline
    yosanpro's Avatar
    Co-Admin
    Join Date
    Nov 2007
    Location
    Bantul, Bantul, Yogyakarta
    Posts
    2,548
    Reviews
    Read 0 Reviews
    Downloads
    11
    Uploads
    4
    Feedback Score
    1 (100%)
    Sep sep, musti banyak belajar lagi ne...

    anyway, thanks for sharing...

  6. #4
    Status
    Offline
    zinhell's Avatar
    Member
    Join Date
    Sep 2008
    Location
    Salatiga
    Posts
    184
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    0
    ciyeee .. cuit cuit ... mattnux top dagh hehehehe .... Click here to enlarge

  7. #5
    Status
    Offline
    ud1geol's Avatar
    Member
    Join Date
    Feb 2008
    Posts
    172
    Reviews
    Read 0 Reviews
    Downloads
    1
    Uploads
    0
    Feedback Score
    1 (100%)
    bedanya ama squid apa yah?
    Click here to enlarge

  8. #6
    Status
    Offline
    mattnux's Avatar
    Forum Guru
    Join Date
    Jun 2008
    Location
    jakarta
    Posts
    1,255
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    1 (100%)
    Click here to enlarge Originally Posted by ud1geol Click here to enlarge
    bedanya ama squid apa yah?
    Click here to enlarge
    squid bisa juga dibuat jadi reverse proxy
    untuk squid biasa yg sering anda2 gunakan prinsipnya menyediakan kebutuhan internal network, sedangkan reverse proxy gunanya untuk menyediakan kebutuhan eksternal network akan konten web dalam internal network kita, gunanya ya sama2 mempercepat balasan request http yang diminta.

    kenapa menggunakan haproxy karena emang haproxy dibuat lebih untuk reverse proxy, sama seperti varnish Click here to enlarge

    hehe buat bro zinhell, mantab juga td ngobrol2nya, sharing2 ilmu sambil ngopi dan ngudud di cafe enak juga hahaha, kayanya kita bisa join buat kantor aja nih Click here to enlarge

  9. #7
    Status
    Offline
    zinhell's Avatar
    Member
    Join Date
    Sep 2008
    Location
    Salatiga
    Posts
    184
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    0
    hahahhahahahhahaha .... tq di bayari wkawakkwakwkwak ..... Click here to enlarge Click here to enlarge

  10. #8
    Status
    Offline
    mattnux's Avatar
    Forum Guru
    Join Date
    Jun 2008
    Location
    jakarta
    Posts
    1,255
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    1 (100%)
    Click here to enlarge Originally Posted by zinhell Click here to enlarge
    hahahhahahahhahaha .... tq di bayari wkawakkwakwkwak ..... Click here to enlarge Click here to enlarge
    besok2 aku yang kesalatiga ya di jamu juga hehehe, kemarin itu aku bayari karena jadi tuan rumah wakakaka Click here to enlarge lagian cuman seiprit koq bayarinnya Click here to enlarge

  11. #9
    nuxer
    nuxer's Avatar
    Bro mattnux saya sudah setup haproxy , cuman sering kali server apachenya di web server 1 dan web server 2 yang dibalancing down.
    Apa penyebabnya dan mohon solusinya.

  12. #10
    Status
    Offline
    deadsoul's Avatar
    Baru Gabung
    Join Date
    Jul 2009
    Posts
    5
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    0
    Nice sharing, bro..

  13. #11
    Status
    Offline
    rud_variant's Avatar
    Baru Gabung
    Join Date
    Feb 2008
    Location
    Kota Padang, Indonesia
    Posts
    7
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    0
    thanks for sharingClick here to enlarge

  14. #12
    Status
    Offline
    unisoviet's Avatar
    Baru Gabung
    Join Date
    Mar 2011
    Posts
    5
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    0
    thanks for sharing, mencoba memahami

 

 

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Similar Articles

  1. [VID] Tutorial Load Balancing & Failover
    By brain_devil2006 in forum Tutorial
    Replies: 51
    Last Post: 30-06-2012, 09:18
  2. Replies: 18
    Last Post: 11-01-2010, 01:29
  3. [SELL] Pigtail UFL to NFemale, HIGH QUALITY COAX
    By unlimited_me in forum Others Hardware
    Replies: 165
    Last Post: 22-12-2009, 12:01
  4. load balancing untuk gamenet
    By anshor in forum Beginner Basics
    Replies: 8
    Last Post: 27-03-2009, 15:05
  5. Replies: 5
    Last Post: 29-04-2008, 12:16

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •