Scenarios for MongoDB high Availability cluster configuration

Source: Internet
Author: User
Tags database sharding


>> High-availability clustering solutions

Ha (high availability) refers to increasing the availability of systems and applications by minimizing downtime due to routine maintenance operations (planning) and sudden system crashes (unplanned).


The high availability of computer systems has different manifestations on different levels:



(1) Network high Availability



Because of the rapid development of network storage, network redundancy technology is continuously promoted, the key application to improve the high availability of IT system is network high availability, network high availability and network high reliability is different, network high availability is through matching redundant network equipment to realize the redundancy of network equipment, achieve high availability.
such as redundant switches, redundant routers, etc.



(2) Server high Availability



Server high availability is mainly achieved by using server cluster software or highly available software.



(3) Storage high Availability



Use software or hardware technology to achieve high availability of storage. Its main technical indicators are storage switching function, data copy function, data snapshot function and so on. When one storage fails, another standby storage can be quickly switched to a storage non-stop.





>>mongodb High-availability cluster configuration


Highly available cluster, i.e. high availability Cluster, referred to as Ha Cluster.
A cluster (cluster) is a group of computers that provide users with a set of network resources as a whole.
These individual computer systems are nodes of the cluster.
Building a high-availability cluster requires a reasonable configuration of roles, data recovery, and consistency among multiple computers, mainly in the following ways:



(1) Master-slave mode (asymmetric mode)



Host work, standby machine in the monitoring readiness; When the host is down, the standby machine takes over all the work of the host, after the host is back to normal, according to the user's settings to automatically or manually switch service to the host, the data consistency through the shared storage system to solve.



(2) dual-machine duplex mode (Mutual aid)



Two hosts simultaneously run their own service work and monitoring the situation, when any one host downtime, another host immediately take over all its work, to ensure that the work in real-time, the application service system Key data stored in the shared storage system.



(3) How the cluster works (multi-server mutual preparation method)



Multiple hosts work together to run one or several services, each defining one or more alternate hosts for the service, and when a host fails, the service running on it can be taken over by another host.



Several scenarios for MongoDB cluster configuration also follow these workarounds.





>>master-slave Master-Slave structure





The master-slave architecture is typically used for backup or read/write separations. Generally there is one master one from design and one master multiple from design.



Consisting of two roles:



(1) Master (Master)



Readable and writable, Oplog are synchronized to all connected salve when the data is modified.



(2) from (Slave)



Read-only non-writable, automatically synchronizing data from master.



In particular, for MongoDB, it is not recommended to use the Master-slave architecture, because Master-slave, where master is not automatically recovered after the outage, the recommended use of replica Set, followed by the introduction, unless the number of replica nodes more than 50, Only need to use the Master-slave architecture, it is not possible to use so many nodes in normal circumstances.



Also, Master-slave does not support chained structures, slave can only connect directly to Master. Redis's master-slave support chain structure, slave can connect slave, become slave slave.





>>relica Set replica set mode


MongoDB's replica set is a replica set of two purposes, one is data redundancy for failure recovery use, when a hardware failure or other causes of downtime, you can use a copy for recovery.



The other is to do the read and write separation, read the request shunt to the copy, alleviate the main (Primary) reading pressure.



1.Primary and secondary-built replica Set






Replica set is a collection of instances of Mongod that have the same data content. Contains three types of roles:



(1) Master node (Primary)



Receive all write requests, and then synchronize the changes to all secondary. A replica set can have only one primary node, and when primary is hung, the other secondary or arbiter nodes will be re-elected to a master node. The default read request is also addressed to the primary node, which needs to be forwarded to the secondary client to modify the connection configuration.



(2) Replica node (secondary)



Keep the same data set as the primary node. When the primary node hangs, participate in the selection of the master.



(3) Arbitrator (arbiter)



Do not retain data, do not participate in the selection of the main vote. The use of arbiter can alleviate the hardware requirements of data storage, arbiter run up with little hardware resource requirements, but it is important that in the production environment it and other data nodes are not deployed on the same machine.



Note that an auto-failover must have an odd number of replica set nodes in order to have a majority to select the primary vote.



(4) Select the main process



Where secondary downtime, not affected, if primary down, will be re-selected master:






2. Build replica Set with arbiter



An even number of data nodes, plus a arbiter composed of replica set mode:








>>sharding Shard Technology


When the amount of data is relatively large, we need to run the data shards in different machines to reduce the CPU, memory and IO pressure, sharding is the database sharding technology.



MongoDB Shard Technology is similar to MySQL horizontal and vertical slicing, the database is mainly made up of two ways sharding: vertical expansion and horizontal slicing.



The way to expand vertically is to expand the cluster, adding more CPU, memory, disk space, and so on.



Horizontal segmentation is through the way of data sharding, unified service through the cluster:






(1) MongoDB's sharding architecture






(2) roles in the MongoDB shard architecture



A. Data fragmentation (shards)



It is used to save data to ensure high availability and consistency of data. Can be a separatemongodinstance, or it can be a replica set.










B. Querying a route (query routers)



Routing is an instance of MONGOs, where the client connects MONGOs directly to the MONGOs to route the read and write requests to the specified shard.



A sharding cluster can have a mongos or multiple mongos to relieve the pressure on the client request.




C. Configuration server (config servers)



Save the cluster's metadata (metadata), which contains the routing rules for each shard.






Reference:



Baidu Encyclopedia-High Availability Cluster



MongoDB Tutorials






Scenarios for MongoDB high Availability cluster configuration


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.