6. Non-relational database (NOSQL) MongoDB: Cluster (master-slave replication)

Source: Internet
Author: User



1. Master-slave replication is MongoDB The most commonly used replication method, which is very flexible and can be used for backup, failure recovery, read extension, etc.

2 The most basic way to set up is to establish a master node and one or more slave nodes, each from the node to know the address of the master node. The primary server is started by running Mongod–master. Running mongod–slave–source master_address initiates the slave server, where master_address is the address of the primary node above.

4 respectively in F : Create two folders under disk to store the data from the master node and the slave node, respectively

5 Start a master node

mongod--dbpath=f:/master--port 27107–master (port number can be specified automatically, but preferably larger)

6 start a Slave node

Mongod--dbpath=f:/slave--port 20000--slave--source localhost:27017

7 start two clients, connecting the master node and the slave node respectively

MONGO localhost:27017

Execute command:

Use Toto

for (var I = 1;i<=10000;i++) {

Db.c2.insert ({name: "Zhangsan", age:i});

}

MONGO localhost:20000

show dbs;

use Toto

db.c2.find ();

< Span style= "Font-family:calibri" >db.c2.insert ({name: "Lisi"}); This time found to add not to go in

Conclusion: Master-slave replication

A only query operations from nodes

B after the primary node is down, the slave node cannot be automatically replaced.

This cluster is only used to back up data

6. Non-relational database (NOSQL) MongoDB: Cluster (master-slave replication)

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.