HAproxy
+++++++++++++Info+++++++++++
VIP:192.168.1.222
HA-Master IP:192.168.1.117
HA-Backup IP:192.168.1.118
Realserver1IP:192.168.1.120
Realserver2IP:192.168.1.121
service iptables stop
chkconfig iptables off
setenforce 0
getenforce ->Permissive
++++++++++++keepalived+chk_haproxy.sh+++++++++MASTER and BACKUP
global_defs {
router_id LVS_DEVEL
}
vrrp_script chk_haproxy {
script "/etc/keepalived/chk_haproxy.sh"
interval 2
weight 2
}
vrrp_instance VI_1 {
state MASTER #BACKUP
interface eth0
virtual_router_id 51
priority 100 #99
advert_int 1
mcast_src_ip 192.168.1.177 #MASTER or BACKUP IP
authentication {
auth_type PASS
auth_pass 111111
}
track_script {
chk_haproxy
}
virtual_ipaddress {
192.168.1.222 #VIP
}
}
-------------------------------------------------chk_haproxy.sh on MSTER and BACKUP
status=$(ps aux|grep haproxy | grep -v grep | grep -v bash | wc -l)
if [ "${status}" = "0" ]; then
/etc/init.d/haproxy start
status2=$(ps aux|grep haproxy | grep -v grep | grep -v bash |wc -l)
if [ "${status2}" = "0" ]; then
/etc/init.d/keepalived stop
fi
fi
++++++++++++keepalived+chk_haproxy.sh+++++++++
service keepalived start
++++++++++++HAPROXY.CFG+++++++++
global
# local2.* /var/log/haproxy.log
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user root
group root
daemon
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 10000
listen stats
mode http
bind 0.0.0.0:
stats enable
stats hide-version
stats uri /haproxyadmin?stats
stats realm Haproxy\ Statistics
stats auth admin:admin
stats admin if TRUE
frontend http-in
bind *:80
mode http
log global
option httpclose
option logasap
option dontlognull
capture request header Host len 20
capture request header Referer len 60
default_backend servers
frontend healthcheck
bind :1099
mode http
option httpclose
option forwardfor
default_backend servers
backend servers
balance roundrobin
server websrv1 192.168.1.121:80 check maxconn 3000
server websrv2 192.168.1.120:80 check maxconn 3000
++++++++++++HAPROXY.CFG+++++++++
service keepalived start
http://192.168.1.177:1080/haproxyadmin?stats username:admin Password:admin
=========================MARK For ab -n 3000 -c 3000 http://192.168.1.222/
ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 3720
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 3720
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
=================
|| ulimit -n 6000 ||
=================
=========================MARK