RSS구독하기:SUBSCRIBE TO RSS FEED
즐겨찾기추가:ADD FAVORITE
글쓰기:POST
관리자:ADMINISTRATOR

Install and Configure HAProxy on CentOS/RHEL 5/6

Linux Tutorials 5 Comments

HAProxy is a very fast and reliable solution for high availability, load balancing, It supports TCP and HTTP-based applications. Now a days most of websites need 99.999% uptime for there site, which are not possible with single server setup. Then we need some high availability environment which can easily manage with single server failure.

haproxy-setup-diagram

This article will help you to install HAProxy on CentOS, RHEL servers and will configure a Layer 4 Load Balancing (Transport Layer). Which will balance load and transfer requests to different-2 servers based on IP address and port numbers.

Setup Instructions:

Step 1: Setup Yum Repository

CentOS/RHEL 5 users required to add EPEL repository in order to install HAProxy packages. For CentOS 6 HAProxy packages are available under base repository, So there are no need to add any repository for them.

On CentOS/RHEL 5:

# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Step 2: Install HAProxy

Install HAProxy package using yum package manager from command line interface using following comamnd.

# yum install haproxy
Step 3: Configure HAProxy

Update your HAProxy configuration file /etc/haproxy/haproxy.cfg as per your requirement, You may also use below given configuration file as an example of setup and modify it.

# vim /etc/haproxy/haproxy.cfg
[ Update red mark values as per your network setup ]
global
        log 127.0.0.1   local0
        log 127.0.0.1   local1 debug
        maxconn   45000 # Total Max Connections. This is dependent on ulimit
        daemon
        nbproc      1 # Number of processing cores. Dual Dual-core Opteron is 4 cores for example.
defaults
        timeout server 86400000
        timeout connect 86400000
        timeout client 86400000
        timeout queue   1000s
        
# [HTTP Site Configuration]
listen  http_web 192.168.10.10:80
        mode http
        balance roundrobin  # Load Balancing algorithm
        option httpchk
        option forwardfor
        server server1 192.168.10.100:80 weight 1 maxconn 512 check
        server server2 192.168.10.101:80 weight 1 maxconn 512 check

# [HTTPS Site Configuration]
listen  https_web 192.168.10.10:443
        mode tcp
        balance source# Load Balancing algorithm
        reqadd X-Forwarded-Proto:\ http
        server server1 192.168.10.100:443 weight 1 maxconn 512 check
        server server2 192.168.10.101:443 weight 1 maxconn 512 check  

Change the ips in configuration file as per your network setup. In HTTP Site Configuration section if any request on ip 192.168.10.10 on port 80, this will be redirected to port 80 of 192.168.10.100 or 192.168.10.101 servers. Similarly in HTTPS Site Configuration if any request on ip 192.168.10.10 on port 443, this will be redirected to port 443 of 192.168.10.100 or 192.168.10.101 servers.

You also need to make few changes in configuration file as per your system configuration.

nbproc <value>    # Number of processing cores in your system.
mode <value>      #  'http' for http site and 'tcp' for https site
balance <value>   # Type of load balancing like 'source', 'roundrobin' etc.
Step 4: Start HAProxy Service

Start HAProxy service using following command, also configure it to auto start on system boot.

# service haproxy start
# chkconfig haproxy on

And You have done it.

Congratulation’s! you have successfully configured HAProxy load balancer. Read next article to enable haproxy stats and setup ACL in HAProxy.

For more configuration details check below url. http://haproxy.1wt.eu/download/1.4/doc/configuration.txt

2016/01/12 17:39 2016/01/12 17:39
http://zosel.net/trackback/234
from.Ugg Europa  2016/01/17 21:38
white nike air max trainers
ZOSEL:Too much is as bad as too little...!! 자공(子貢)이 공자에게 "사(師:子張의 이름)와 상(商:子夏의 이름)은 어느 쪽이 어집니까?" 하고 묻자, 공자는 "사는 지나치고 상은 미치지 못한다"고 대답하였다. "그럼 사가 낫단 말씀입니까?" 하고 반문하자, 공자는 "지나친 것은 미치지 못한 것과 같다(過猶不及)"고 말하였다.
Too much is as bad as too little...!! 자공(子貢)이 공자에게 "사(師:子張의 이름)와 상(商:子夏의 이름)은 어느 쪽이 어집니까?" 하고 묻자, 공자는 "사는 지나치고 상은 미치지 못한다"고 대답하였다. "그럼 사가 낫단 말씀입니까?" 하고 반문하자, 공자는 "지나친 것은 미치지 못한 것과 같다(過猶不及)"고 말하였다.
전체 (209)
리눅스시스템 (92)
윈도우시스템 (16)
프로그램 (7)
네트워크시스템 (7)
최근관심 (1)
«   2024/05   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
  1. yeezyboost-350.co.uk  2021
    yeezyboost-350.co.uk
  2. 강남역 풀싸롱  2021
    강남역 풀싸롱
  3.   2021
  1. 2018/02 (1)
  2. 2017/03 (2)
  3. 2016/12 (2)