Use HAProxy as MongoDB sharded cluster mongos Load Balancing
MongoDB shard cluster entry mongos does not have a failover mechanism. The official recommendation is to deploy mongos and the application server together. It is inconvenient to deploy multiple mongos instances for multiple application servers. You can also use LVS or HAProxy to implement the failover mechanism for multiple mongos, but be sure to use client affinity, that is, the client Association feature.
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
Ults
Log global
Mode tcp
Option abortonclose
Option allbackups
Option tcpka
Option redispatch
Retries 3
Timeout check 60 s
Timeout connect 600 s
Timeout queue 600 s
Timeout server 600 s
Timeout tarpit 60 s
Timeout client 600 s
Frontend ipvs_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 2 s fastinter 1 s downinter 5S slowstart 60 s 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
Note
Balance source
MongoDB 3.0 official version released and downloaded
CentOS compilation and installation of MongoDB
CentOS compilation and installation of php extensions for MongoDB and mongoDB
CentOS 6 install MongoDB and server configuration using yum
Install MongoDB2.4.3 in Ubuntu 13.04
MongoDB beginners must read (both concepts and practices)
MongoDB Installation Guide for Ubunu 14.04
MongoDB authoritative Guide (The Definitive Guide) in English [PDF]
Nagios monitoring MongoDB sharded cluster service practice
Build MongoDB Service Based on CentOS 6.5 Operating System
MongoDB details: click here
MongoDB: click here
This article permanently updates the link address: