搭建keepalived+haproxy双主高可用负载均衡系统

来自linux中国网wiki
跳到导航 跳到搜索
搭建keepalived+haproxy双主高可用负载均衡系统

基础知识普及

常用高可用软件 keepalived heartbeat 常用负载均衡器 nginx haproxy LVS

常用方案为 haproxy +Keepalived 或者 nginx +Keepalived

我们这里用 haproxy +Keepalived

搭建环境描述

vip 192.168.30.88

haproxy-server(haproxy+keepalived) 192.168.30.75 backup-haproxy(haproxy+keepalived) 192.168.30.76

webapp1 192.168.30.71 webapp2 192.168.30.72

os CentOS Linux release 7.3.1611

软件安装

haproxy

Haproxy安装和配置

keepalived

keepalived安装和配置

在master上配置HAProxy和Keepalved

master HAProxy 和 Backup HAProxy 配置是一样的 见 Haproxy安装和配置

在Backup上配置HAProxy和Keepalved

master Keepalved 和 Backup Keepalved 配置 基本一样

其中 master Keepalved 为 priority 100 ; backup Keepalved 为 priority 90, 还有 如果配置的是不抢占模式 ,还要 在bakc 上去掉 nopreempt选项


测试

192.168.30.88 www.zb.com 192.168.30.88 static.zb.com




问题及解决过程

 这个是比较 好用的参考 谢谢作者了
keepalived+haproxy双主高可用负载均衡
http://nmshuishui.blog.51cto.com/1850554/1405486

#./configure --sysconf=/etc  --with-kernel-dir=/usr/src/kernels/3.10.0-514.el7.x86_64

make 

usr/src/kernels/3.10.0-514.el7.x86_64/include/linux/linkage.h:7:25: 致命错误:asm/linkage.h:没有那个文件或目录
 #include <asm/linkage.h>
                         ^
编译中断。
make[2]: *** [smtp.o] 错误 1
make[2]: 离开目录“/root/keepalived-1.2.12/keepalived/core”
make[1]: *** [all] 错误 1
make[1]: 离开目录“/root/keepalived-1.2.12/keepalived”
make: *** [all] 错误 2

#4 centos7
./configure --sysconf=/etc  --with-kernel-dir=/usr/src/kernels/3.10.0-514.el7.x86_64
make -j3

                 from ../include/smtp.h:34,
                 from smtp.c:27:
/usr/src/kernels/3.10.0-514.el7.x86_64/include/linux/linkage.h:7:25: 致命错误:asm/linkage.h:没有那个文件或目录
 #include <asm/linkage.h>
                         ^
编译中断。
make[2]: *** [smtp.o] 错误 1
make[2]: 离开目录“/root/keepalived-1.2.12/keepalived/core”
make[1]: *** [all] 错误 1
make[1]: 离开目录“/root/keepalived-1.2.12/keepalived”
make: *** [all] 错误 2

今天 没带 -with-kernel-dir 因为是lvs才一定要用上这个 

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Load_Balancer_Administration/s2-lvs-keepalived-haproxy-VSA.html

参考

HAProxy负载均衡与keepalived搭建高可用负载均衡web(Nginx/PHP/Tomcat)集群

haproxy+keepalived实现高可用负载均衡

haproxy配置详解 http://leejia.blog.51cto.com/4356849/1421882


负载均衡工具haproxy安装,配置,使用 http://blog.51yip.com/server/868.html

keepalived+haproxy双主高可用负载均衡 http://nmshuishui.blog.51cto.com/1850554/1405486


apache+Keepalived实现站点高可用 http://blog.linuxchina.net/?p=2942

keepalived 搭建LVS高可用 Cluste http://blog.linuxchina.net/?p=1741


Nginx+Keepalived实现站点高可用 http://seanlook.com/2015/05/18/nginx-keepalived-ha/

企业集群平台架构实现与应用实战(HAproxy+keepalived篇)


负载均衡-haproxy安装配置


Keepalived+Nginx实现高可用Web负载均衡 http://www.jianshu.com/p/da26df4f7d60

nginx+keepalived高可用及双主模式 http://noodle.blog.51cto.com/2925423/1794734

Nginx+Keepalived实现站点高可用 https://segmentfault.com/a/1190000002881132

Wed负载均衡高可用之Nginx+keepalived http://luozlinux.blog.51cto.com/1388902/1227004


烂泥:高负载均衡学习haproxy之配置文件详解 http://www.ilanni.com/?p=10016