博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Haproxy+keepalived实现sphinx高可用负载均衡
阅读量:6206 次
发布时间:2019-06-21

本文共 2976 字,大约阅读时间需要 9 分钟。

  hot3.png

Haproxy+keepalived实现sphinx高可用负载均衡 环境如下: 【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 # 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.解决办法: # apt-get install libssl-dev configure: error: Popt libraries is required 解决办法: # apt-get install libpopt-dev configure: WARNING: keepalived will be built without libnl support. 解决办法: # 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’ 解决办法: # vim ./keepalived/libipvs-2.6/ip_vs.h 将#include <linux/types.h>移动到#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 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

转载于:https://my.oschina.net/766/blog/210962

你可能感兴趣的文章
从Mysql slave system lock延迟说开去
查看>>
归并排序
查看>>
RecyclerView的下拉刷新和加载更多 动画
查看>>
ABAP常见面试问题
查看>>
HBase-1.2.4LruBlockCache实现分析(一)
查看>>
SDN交换机在云计算网络中的应用场景
查看>>
革新以太网交换机架构 全光网络的风刮进园区
查看>>
物联网商机迸发 LPWAN芯片现身 本文转自d1net(转载)
查看>>
【eclipse转idea的第一天】配置idea
查看>>
error: Refusing toundefine while domain managed save image exists
查看>>
wordpress在新窗口打开留言者链接
查看>>
java开发过程中的命名规范
查看>>
mysql索引随记
查看>>
分布式配置管理平台Disconf
查看>>
pdf 字体和图片抽取
查看>>
Cisco Nexus 1000V
查看>>
我的友情链接
查看>>
[iOS Animation]-CALayer 性能优化实例
查看>>
CentOS多网卡重命名配置
查看>>
变态青蛙跳
查看>>