Introduction to MongoDB replica Sets

Source: Internet
Author: User

In recent years, with the increasing popularity of big data, the importance of non-relational databases has been recognized by more and more people, and more developers have gradually joined the NoSQL camp. We know that NoSQL means Not Only SQL. In this case, the features supported by many relational databases are also applicable to non-relational data, such as replica sets.


MongoDB supports data replication. It has the same advantages as other data replication sets. It deploys data on multiple different servers, to prevent data loss due to a single machine failure, data redundancy is used to improve data reliability and security. The replication technology can also be used to build distributed databases to improve system access performance and security.
The replica set mode of MongoDB is master-slave replication. Among all database service machines, only one machine plays the Primary role, and the other machines are Secondaries. The machine that assumes the Primary role receives all Write operation requests from the client and completes the operation to ensure data consistency. The machine that assumes the Primary role can also allocate Read operations from the client to other machines (Secondaries) to relieve the pressure on the master database server.
So how does MongoDB replicate data on various machines?
It turns out that the Primary database of MongoDB records these operations in the oplog log file every time it updates the data. The Secondaries database reads and executes logs locally through asynchronous operations to generate data consistent with Primary.
When the Primary database is unavailable, the replica set selects a machine from Secondaries as the Primary machine. By default, the client reads data from the Primary machine, but the client can also specify the copy from which the data is read.
We can also configure an arbitration server. Arbitration does not manage replica sets, nor can it become Primary. It only determines which replica sets have the right to become Primary.
The above is the main content of the MongoDB replica set. If you have any questions, please leave a comment.


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.