In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following will give you a detailed explanation of how to build a highly available load balancer mongodb for HAProxy+mongos. I hope it can give you some help in practical application. There are many things involved in load balancing, and there are not many theories. There are many books online. Today, we will use the accumulated experience in the industry to do an answer.
In the production environment, the built mongodb slicing provides three mongos interfaces. However, there is no failover mechanism in mongodb. It is officially recommended that mongos and application cloud servers be deployed together, and multiple mongos instances should be deployed to multiple application servers, which is very inconvenient. Check that there are several ways to make use of all three mongos interfaces to reduce the pressure on a single interface. The commonly used ones are LVS and HAProxy. So try to use HAProxy for load balancing.
HAProxy is a proxy software that provides high availability, load balancing and based on TCP and HTTP applications. HAProxy is completely free. With the help of HAProxy, you can quickly and reliably provide proxy solutions based on TCP and HTTP applications. HAProxy is suitable for heavily loaded web sites, which usually require session persistence or seven-tier processing. HAProxy can support tens of thousands of concurrent connections, and the operation mode of HAProxy makes it easy and secure to integrate into the architecture, while protecting web servers from being exposed to the network.
Start now, using the Ubuntu64 bit operating system
1. Install HAproxy on Ubuntu:
Sudo apt-get install haproxy
two。 After installation, configure to boot:
Sudo vim / etc/default/haproxy
Change ENABLE=0 to ENABLE=1 save exit
3. Configure haproxy:
Sudo vim / etc/haproxy/haproxy.cfg, modify the contents as follows:
Global
Chroot / data/app_platform/haproxy/share/
User root
Group root
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 172.16.2.230:27017 check maxconn 30000
Server gintama-xxx-mongos2 172.16.2.231:27017 check maxconn 30000
Server gintama-xxx-mongos3 172.16.2.232:27017 check maxconn 30000
Change the corresponding parameters inside to your parameters.
4. Start haproxy:
Based on the startup of mongos, run haproxy, using the following command:
Haproxy-f / etc/haproxy/haproxy.cfg
Open your database client and link to haproxy to view the results
At this point, you have set up the mongodb framework of haproxy+mongos and used all three mongos.
Attached:
Start haproxy:sudo / etc/init.d/haproxy start
Restart haproxy:sudo / etc/init.d/haproxy restart
Close haproxy:sudo / etc/init.d/haproxy stop
After reading the above detailed explanation on how to build a highly available load balancer mongodb in HAProxy+mongos, if there is anything else you need to know, you can find what you are interested in in the industry information or find our professional and technical engineers for answers. Technical engineers have more than ten years of experience in the industry.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.