標籤:haproxy 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_poolbackend 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
本文出自 “Linux SA John” 部落格,請務必保留此出處http://john88wang.blog.51cto.com/2165294/1620384
使用HAProxy作為MongoDB分區叢集mongos負載平衡