中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Haproxy+keepalived如何實現sphinx高可用負載均衡詳解

發布時間:2020-04-17 11:21:13 來源:億速云 閱讀:244 作者:三月 欄目:關系型數據庫

下文給大家帶來Haproxy+keepalived如何實現sphinx高可用負載均衡詳解,希望能夠給大家在實際運用中帶來一定的幫助,負載均衡涉及的東西比較多,理論也不多,網上有很多書籍,今天我們就用億速云在行業內累計的經驗來做一個解答。

Haproxy+keepalived實現sphinx高可用負載均衡  

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 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>移動到#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

看了以上關于Haproxy+keepalived如何實現sphinx高可用負載均衡詳解,如果大家還有什么地方需要了解的可以在億速云行業資訊里查找自己感興趣的或者找我們的專業技術工程師解答的,億速云技術工程師在行業內擁有十幾年的經驗了。

 

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

永修县| 天津市| 武宣县| 射阳县| 灵川县| 乐至县| 永德县| 雷州市| 农安县| 江门市| 宁城县| 诸城市| 金山区| 富民县| 清河县| 梅河口市| 剑川县| 饶平县| 新竹县| 临沭县| 雷山县| 长宁县| 区。| 富源县| 峨眉山市| 安岳县| 营山县| 陕西省| 江永县| 余江县| 无极县| 台东县| 北碚区| 双鸭山市| 扎鲁特旗| 南木林县| 汉寿县| 晋中市| 正安县| 玛多县| 望江县|