Welcome 微信登录

首页 / 数据库 / MySQL / 使用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 sourceMongoDB 3.0 正式版发布下载  http://www.linuxidc.com/Linux/2015-03/114414.htmCentOS编译安装MongoDB http://www.linuxidc.com/Linux/2012-02/53834.htmCentOS 编译安装 MongoDB与mongoDB的php扩展 http://www.linuxidc.com/Linux/2012-02/53833.htmCentOS 6 使用 yum 安装MongoDB及服务器端配置 http://www.linuxidc.com/Linux/2012-08/68196.htmUbuntu 13.04下安装MongoDB2.4.3 http://www.linuxidc.com/Linux/2013-05/84227.htmMongoDB入门必读(概念与实战并重) http://www.linuxidc.com/Linux/2013-07/87105.htmUbunu 14.04下MongoDB的安装指南 http://www.linuxidc.com/Linux/2014-08/105364.htm《MongoDB 权威指南》(MongoDB: The Definitive Guide)英文文字版[PDF] http://www.linuxidc.com/Linux/2012-07/66735.htmNagios监控MongoDB分片集群服务实战 http://www.linuxidc.com/Linux/2014-10/107826.htm基于CentOS 6.5操作系统搭建MongoDB服务 http://www.linuxidc.com/Linux/2014-11/108900.htmMongoDB 的详细介绍:请点这里
MongoDB 的下载地址:请点这里本文永久更新链接地址