1. Replica set
The master-slave deployment of MongoDB is commonly used in the form of a replica set (replica set). Replica set is a set of multiple Mongod instances that comprise a group of groups, including a master primary, and multiple from secondary. The advantage of this one master multi-slave approach is that MongoDB self-ops, if the main server hangs, will be automatically detected by heartbeat, elect a new master to come. No manual processing is required.
2. Master-Slave
Three machines do an example, a master two from.
There is a heartbeat between the primary and the slave to detect whether it is active. Each 2s heartbeat each other, if there is no return status within 10 seconds, the service is marked as discarded, inaccessible state. If the master hangs up. Then elect the new Lord out.
Then again is the new master-slave pattern.
3. Data synchronization
MongoDB's data write will fall to primary. Primary the Oplog of the build operation. Receives the Oplog of the Lord's primary from secondary. The asynchronous process is then called to write from the data. Each master-slave synchronization is updated with Optime. The election of the new master is determined by Optime, and the newest optime will be chosen as the new Lord. A replica set can have one or more from secondary.
Address: http://blog.csdn.net/yonggang7/article/details/38778373
MongoDB Master-slave configuration: Replica set replica set