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 #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: the
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
server websrv2 192.168.1.120:80 check maxconn
++++++++++++haproxy. cfg+++++++++
Service keepalived Start
Http://192.168.1.177:1080/haproxyadmin?stats Username:admin Password:admin
=========================mark for Ab-n 3000-c 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 (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
Linux-haproxy+keepalived