In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following gives you a detailed explanation of Haproxy+keepalived how to achieve sphinx high-availability load balancer, hoping to bring some help to you in practical application. Load balancing involves more things, there are not many theories, and there are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.
Implementing sphinx High availability load balancing with Haproxy+keepalived
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 include 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 behind # include.
#. / configure-prefix=/usr/local/keepalived-1.2.2
Keepalived configuration
-
Keepalived version: 1.2.2
Compiler: gcc
Compiler flags:-g-O2
Extra Lib:-lpopt-lssl-lcrypto-lnl
Use IPVS Framework: Yes
IPVS sync daemon support: Yes
IPVS 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_id LVS_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
Priority 150
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 BACKUP
Interface eth0
Virtual_router_id 77
Priority 100
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
Priority 100
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
Priority 150
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 | grep haproxy | 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
Fi
After reading the above detailed explanation on how Haproxy+keepalived implements sphinx high-availability load balancer, if you have anything else you need to know, you can find out what you are interested in in the industry information or find our professional and technical engineer for answers. Technical engineers have more than ten years of experience in the industry.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.