Mongodb distributed cluster (1. Master-slave replication), mongodb master-slave

Source: Internet
Author: User

Mongodb distributed cluster (1. Master-slave replication), mongodb master-slave
Understanding of distributed Clusters

There are many explanations on the concept of distributed clusters. I prefer "distributed clusters" as two concepts, that is, distributed is one concept and cluster is another.

Distributed is to divide an entire system into multiple parts and deploy them on different servers. Then, the central server is centrally controlled to form an external system. A cluster is the result of deploying the entire cluster to multiple servers.

Both the distributed architecture and the cluster architecture are described in terms of deployment. They all involve the deployment of multiple servers. This is the same as the distributed architecture and cluster architecture. Of course, the distributed architecture achieves many similar results. However, they describe two different phenomena. Let's talk about the mongodb distributed cluster today.


Mongodb distributed Cluster

Mongodb's distributed cluster mainly includes master-slave replication, replica set, and sharding, and the combination of sharding and replica set. The main content of this blog is the configuration of master-slave replication, then, the relevant blog will describe several other distributed clusters.


Deployment Diagram


Master-slave replication Configuration
// Command Window input // master server (slaves table Storage Association information of local database) mongod -- dbpath C: /data/master -- port 10000 -- master // slave server (the sources table Storage Association information of the local database) mongod -- dbpath C: /data/slave1 -- port 10001 -- slave -- source 192.168.24.131: 10000 // Add slave server mongod -- dbpathC:/data/slave2 -- port 10002 -- slave -- source 192.168.24.131: 20000

The configuration of the master-slave server is very simple, just add some parameters when starting the server.

Use the client to connect to the master server, and then insert a number. At this time, when we connect to the slave server using the client, we can query the inserted data.

<Span style = "font-size: 18px;"> // The primary server mongo 127.0.0.1: 27017/test // Add (add set and record) db.doc umentName. insert ({name: "qingshan", age: 25}); // query db.doc umentName. find (); // The slave server mongo 127.0.0.1: 27017/test // You can query the data inserted by the master server db.doc umentName. find (); </span>
 

Advantages and disadvantages of master-slave ReplicationAdvantages

Read/write Splitting: read/write data on the master node. Data on the slave node is read-only and cannot be manually inserted on the slave node.

Data backup: The slave node completely backs up the disadvantages of the master database data

Disadvantages

When the master server fails, manual intervention is generally performed to specify the new master


Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.