使用HAProxy作為MongoDB分區叢集mongos負載平衡

來源:互聯網
上載者:User

使用HAProxy作為MongoDB分區叢集mongos負載平衡

MongoDB分區叢集的入口mongos自身沒有failover機制。官方建議是將mongos和應用伺服器部署在一起,多個應用伺服器就要部署多個mongos執行個體,這樣很是不方便。還可以使用LVS或者HAProxy來實現多個mongos的failover機制,但是一定要注意使用client affinity即用戶端關聯特性。

global
    chroot      /data/app_platform/haproxy/share/ 
    log        127.0.0.1 local3 info
    daemon     
    user        haproxy
    group      haproxy
    pidfile    /var/run/haproxy.pid
    nbproc      1                       
    stats socket  /tmp/haproxy level admin
    stats maxconn 20                   
    node        master_loadbalance1
    description lb1
    maxconn    65536
    nosplice                           
    spread-checks 3                     
 
defaults
    log        global                 
    mode tcp
    option abortonclose         
    option allbackups           
    option tcpka                       
    option redispatch
    retries 3   
    timeout check 60s                   
    timeout connect 600s                           
    timeout queue 600s                   
    timeout server 600s                 
    timeout tarpit 60s
    timeout client 600s   
     
     
     
frontend  mongos_pool 0.0.0.0:28018
    mode tcp
    maxconn 32768
    no option dontlognull
    option tcplog     
    log        global
    option log-separate-errors
    default_backend mongos_pool
 
backend mongos_pool
    mode tcp
    balance    source
    default-server inter 2s fastinter 1s downinter 5s slowstart 60s rise 2 fall 5 weight 30
 
    server  gintama-xxx-mongos1  192.168.100.74:28018    check  maxconn 2000
    server  gintama-xxx-mongos2  192.168.100.75:28018    check  maxconn 2000

注意使用
balance source

MongoDB 3.0 正式版發布下載 

CentOS編譯安裝MongoDB

CentOS 編譯安裝 MongoDB與mongoDB的php擴充

CentOS 6 使用 yum 安裝MongoDB及伺服器端配置

Ubuntu 13.04下安裝MongoDB2.4.3

MongoDB入門必讀(概念與實戰並重)

Ubunu 14.04下MongoDB的安裝指南

《MongoDB 權威指南》(MongoDB: The Definitive Guide)英文文字版[PDF]

Nagios監控MongoDB分區叢集服務實戰

基於CentOS 6.5作業系統搭建MongoDB服務

MongoDB 的詳細介紹:請點這裡
MongoDB 的:請點這裡

本文永久更新連結地址:

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.