Last active
January 3, 2016 08:09
-
-
Save kenshinx/8433935 to your computer and use it in GitHub Desktop.
Keepalived + Haproxy VIP: 123.125.22.90
Master: 123.125.22.97
Backup: 123.125.22.98
Server1: 123.125.22.99
Server2: 123.125.22.100
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# author: weizhifeng | |
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 | |
~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this config needs haproxy-1.1.28 or haproxy-1.2.1 | |
global | |
log 127.0.0.1 local3 debug | |
#log 127.0.0.1 local1 notice | |
#log loghost local0 info | |
maxconn 65535 | |
#chroot /usr/share/haproxy | |
user haproxy | |
group haproxy | |
daemon | |
nbproc 1 | |
pidfile /var/run/haproxy.pid | |
#debug | |
#quiet | |
defaults | |
log global | |
mode http | |
option httplog | |
option dontlognull | |
retries 3 | |
redispatch | |
stats enable | |
stats uri /haproxy-status | |
stats refresh 5s | |
maxconn 2000 | |
contimeout 5000 | |
clitimeout 50000 | |
srvtimeout 50000 | |
listen swaf-loadbalance 0.0.0.0:80 | |
cookie SERVERID rewrite | |
balance roundrobin | |
server swaf_99 123.125.22.99:80 cookie app1inst1 check inter 2000 rise 2 fall 5 | |
server sawf_100 123.125.22.100:80 cookie app1inst2 check inter 2000 rise 2 fall 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! Configuration File for keepalived | |
global_defs { | |
notification_email { | |
[email protected] | |
} | |
notification_email_from [email protected] | |
smtp_server mail.sina.com.cn | |
smtp_connect_timeout 30 | |
router_id swaf_haproxy_2 | |
} | |
vrrp_script chk_haproxy { | |
script "/usr/local/keepalived/chk_haproxy.sh" | |
interval 2 | |
weight 2 | |
} | |
vrrp_instance VI_1 { | |
state BACKUP | |
interface eth0 | |
virtual_router_id 21 | |
priority 50 | |
advert_int 1 | |
authentication { | |
auth_type PASS | |
auth_pass sinasec | |
} | |
track_script { | |
chk_haproxy | |
} | |
virtual_ipaddress { | |
123.125.22.90 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! Configuration File for keepalived | |
global_defs { | |
notification_email { | |
[email protected] | |
} | |
notification_email_from [email protected] | |
smtp_server mail.sina.com.cn | |
smtp_connect_timeout 30 | |
router_id swaf_haproxy_1 | |
} | |
vrrp_script chk_haproxy { | |
script "/usr/local/keepalived/chk_haproxy.sh" | |
interval 2 | |
weight 2 | |
} | |
vrrp_instance VI_1 { | |
state MASTER | |
interface eth0 | |
virtual_router_id 21 | |
priority 100 | |
advert_int 1 | |
authentication { | |
auth_type PASS | |
auth_pass sinasec | |
} | |
track_script { | |
chk_haproxy | |
} | |
virtual_ipaddress { | |
123.125.22.90 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
VIP: 123.125.22.90
Master: 123.125.22.97
Backup: 123.125.22.98
Server1: 123.125.22.99
Server2: 123.125.22.100