Haproxy+keepalived如何實(shí)現(xiàn)sphinx高可用負(fù)載均衡詳解

下文給大家?guī)?lái)Haproxy+keepalived如何實(shí)現(xiàn)sphinx高可用負(fù)載均衡詳解,希望能夠給大家在實(shí)際運(yùn)用中帶來(lái)一定的幫助,負(fù)載均衡涉及的東西比較多,理論也不多,網(wǎng)上有很多書(shū)籍,今天我們就用創(chuàng)新互聯(lián)在行業(yè)內(nèi)累計(jì)的經(jīng)驗(yàn)來(lái)做一個(gè)解答。

網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)!專注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、微信小程序開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了泉港免費(fèi)建站歡迎大家使用!

Haproxy+keepalived實(shí)現(xiàn)sphinx高可用負(fù)載均衡  

Haproxy+keepalived如何實(shí)現(xiàn)sphinx高可用負(fù)載均衡詳解環(huán)境如下:
【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.解決辦法:
# 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>移動(dòng)到#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

看了以上關(guān)于Haproxy+keepalived如何實(shí)現(xiàn)sphinx高可用負(fù)載均衡詳解,如果大家還有什么地方需要了解的可以在創(chuàng)新互聯(lián)行業(yè)資訊里查找自己感興趣的或者找我們的專業(yè)技術(shù)工程師解答的,創(chuàng)新互聯(lián)技術(shù)工程師在行業(yè)內(nèi)擁有十幾年的經(jīng)驗(yàn)了。

 

本文題目:Haproxy+keepalived如何實(shí)現(xiàn)sphinx高可用負(fù)載均衡詳解
當(dāng)前地址:http://bm7419.com/article14/isggge.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、微信小程序、動(dòng)態(tài)網(wǎng)站、全網(wǎng)營(yíng)銷推廣、App設(shè)計(jì)標(biāo)簽優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

營(yíng)銷型網(wǎng)站建設(shè)