Haproxy + keepalived for Sphinx high-availability Load Balancing

Source: Internet
Author: User
Tags haproxy
Haproxy + keepalived for Sphinx High Availability Server Load balancer
The environment is as follows:
[Node3]
Haproxy: 192.168.1.189
[Node4]
Haproxy: 192.168.1.103
VIP: 192.168.1.222/192.168.1.223
# Apt-Get install ipvsadm
# Apt-Get install linux-headers-$ ( Uname-R)
# Ln-S/usr/src/linux-headers-2.6.32-33/usr/src/Linux
# Wget http://www.keepalived.org/software/keepalived-1.2.2.tar.gz
# Tar zxvf keepalived-1.2.2.tar.gz-C ../software/
#./Configure-Prefix =/usr/local/keepalived-1.2.2
Configure: Error :!!! OpenSSL is not properly installed on your system .!!!!!! Can not I NCLude OpenSSL Headers FileS. solution:
# Apt-Get install libssl-Dev
Configure: Error: popt libraries is required
Solution:
# Apt-Get install libpopt-Dev
Configure: Warning: keepalived will be built without libnl SuPport.
Solution:
# Apt-Get install libnl-Dev
/Usr/include/stdint. h: 41: Error: conflicting types for 'int64 _ t'
/Usr/src/Linux/include/Linux/types. h: 125: Error: previous declaration of 'int64 _ t' was here
/Usr/include/stdint. h: 56: Error: conflicting types for 'uint64 _ t'
Solution:
# Vim./keepalived/libipvs-2.6/ip_vs.h
Move # include <Linux/types. h> to the end of # include <sys/types. h>.
#./Configure-Prefix =/usr/local/keepalived-1.2.2
Keepalived Configuration
--------
Keepalived version: 1.2.2
Compiler: gcc
Compiler flags:-g-O2
Ex TrA Lib:-lpopt- LsSL-lcrypto-lnl
Use ipvs framework: Yes
Ipvs SyncDaemon support: Yes
S use libnl: Yes
Use vrrp framework: Yes
Use DEBUG flags: No
# Make
# Make install
# Vim/etc/sysctl. conf
Net. ipv4.ip _ nonlocal_bind = 1
# Sysctl-P
[Node3]
Global_defs {
Router _ IDLvs_devel
}
Vrrp_script chk_haproxy {
Script "/usr/local/scripts/chk_haproxy.sh"
Interval 2
Weight 2
}
Vrrp_instance vi_1 {
StatE master
Interface eth0
Virtual_router_id 76
Priority150
Advert_int 1
Authenti CatIon {
Auth_type pass
Auth_pass 123456
}
Track_script {
Chk_haproxy
}
Virtual_ipa DdRESS {
192.168.1.222
}
}
Vrrp_instance vi_2 {
State backup
Interface eth0
Virtual_router_id 77
Priority100
Advert_int 1
Authentication {
Auth_type pass
Auth_pass 123456
}
Track_script {
Chk_haproxy
}
Virtual_ipaddress {
192.168.1.223
}
}
[Node4]
Global_defs {
Router_id lvs_devel
}
Vrrp_script chk_haproxy {
Script "/usr/local/scripts/chk_haproxy.sh"
Interval 2
Weight 2
}
Vrrp_instance vi_1 {
State backup
Interface eth0
Virtual_router_id 76
Priority100
Advert_int 1
Authentication {
Auth_type pass
Auth_pass 123456
}
Track_script {
Chk_haproxy
}
Virtual_ipaddress {
192.168.1.222
}
}
Vrrp_instance vi_2 {
State master
Interface eth0
Virtual_router_id 77
Priority150
Advert_int 1
Authentication {
Auth_type pass
Auth_pass 123456
}
Track_script {
Chk_haproxy
}
Virtual_ipaddress {
192.168.1.223
}
}
# Vim chk_haproxy.sh
#! /Bin/bash
Status =' Netstat-Nptl | GrepHaproxy | grep 3312 | WC-L'
If ["$ status"-EQ "0"]; then
/Usr/local/haproxy-1.4.18/sbin/haproxy-F/usr/local/haproxy-1.4.18/haproxy. conf
Status2 = 'netstat-nptl | grep haproxy | grep 3312 | WC-l'
If ["$ status2"-EQ "0"]; then
Kill-9 $ (PS-Ef | grep keepalived | grep-V grep | awk '{print $2 }')
Fi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.