Replica Set of actual combat mongodb-replication

Source: Internet
Author: User
Tags failover include log mongodb

Actual Combat MongoDB

Master-slave

MongoDB supports asynchronous data replication between different services to implement failover (failover, failover, failback) and redundancy (data redundancy).

At the same time, only one service node (primary or master) supports writing.

MongoDB supports two modes of replication:

Master/slave, master-slave replication, roles include Master and Slave.

Replica set, replica set replication, roles include primary and secondary.

To introduce the official address of Master/slave:

Http://www.mongodb.org/display/DOCS/Master+Slave

Describes the official address of replica set:

Http://www.mongodb.org/display/DOCS/Replica+Sets

Today's actual combat is replica set, that is, replication set replication.

Replica set can implement automatic failover and automatic recovery.

The replica set consists of two or more nodes, which enable each other to replicate.

Replica set automatically selects the primary node, and no node is fixed primary.

MONGOs automatically discovers that a replica set primary node changes and sends writes to the new primary node.

Typically used for the following scenarios

Data redundancy.

Automatic failover, providing high availability services.

Distributed read load.

Simplifies maintenance (as opposed to master-slave).

Disaster recovery.

First or start Mongod, there are two parameters for the replica set:

--replset <setname>, the name of the replica set.

--oplogsize <mb>, the size of the action log, in megabytes.

This time we configure replica set under Ubuntu and start with two mongod nodes first.

Mongod--dbpath/home/andyshi/mongo1/--logpath/home/andyshi/mongo1/log.log--replset shard1--port 10001--bind_ip 192.168.0.21

Mongod--dbpath/home/andyshi/mongo2/--logpath/home/andyshi/mongo2/log.log--replset shard1--port 10002--bind_ip 192.168.0.21

You will notice that the two mongod boot parameters replset Specify the same value Shard1, that is, two mongod nodes are in the same replica set.

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.