HA proxy Inatallation & Configuration

HA proxy Inatallation & Configuration

Installation & Configuration

# yum info haproxy 
# yum install gcc pcre-devel tar make -y 
# wget http://www.haproxy.org/download/2.0/src/haproxy-2.0.7.tar.gz  
# tar xzvf haproxy.tar.gz
 # cd haproxy-2.0.7 

 # make TARGET=linux-glibc 
 # make install 

 # mkdir -p /etc/haproxy 
 # mkdir -p /var/lib/haproxy 
 # touch /var/lib/haproxy/stats 
 # ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
 # cp ~/haproxy-2.0.7/examples/haproxy.init /etc/init.d/haproxy 
 # chmod 755 /etc/init.d/haproxy 
 # systemctl daemon-reload 
 # systemctl enable haproxy 
 # useradd -r haproxy 
 # haproxy –v
 # firewall-cmd --permanent --add-service=http 
 # firewall-cmd --permanent  --add-port=8181/tcp 
 # firewall-cmd --reload 
 # firewall-cmd --list-all
Config File & Directory 
 /etc/haproxy     
Configuration directory 
 /etc/haproxy/haproxy.cfg   
Configuration file 
 /var/log/ haproxy.log
Log file 
HAproxy Configuration: 
 # cd /etc/haproxy/ 
 # vim haproxy.cfg 
          global 
            log /dev/log local0 
            log /dev/log local1 notice 
            chroot /var/lib/haproxy 
            stats timeout 30s 
            user haproxy 
            group haproxy 
            daemon 

         defaults 
            log global 
            mode http 
            option httplog 
            option dontlognull 
            timeout connect 5000 
            timeout client 50000
            timeout server 50000

         frontend http_front 
            bind *:80 
            stats uri /haproxy?stats 
            default_backend http_back 

         backend http_back 
            balance roundrobin 
            server webserver_1 192.168.0.150:80 check 
            server webserver_2 192.168.0.103:80 check
# systemctl restart haproxy 
 # systemctl status haproxy