Replica sets (replica set) is a new feature that starts with the mongodDB1.6 version, which enables automatic failover and automatic repair of feature member nodes, and the data between each db is exactly the same, greatly reducing the risk of a single point of failure.
【】
This is the replica set schema for three nodes. The figure is from the book "The Essentials of MongoDB Management and development" written by Red pill. As can be seen, the structure is similar to a cluster, in fact, can be regarded as a cluster. Because it does have the same effect as the cluster implementation.
First, deploy replica sets.
Next shows how to demonstrate the deployment of a 3-node replica on a single server sets
Second, start replica service
Open three command Windows respectively, and then perform the following three sentences, respectively.
Mongod.exe --replset rs1--keyfile "D:\Program files\mongodb\data\replica\key\r0"--port 28010--dbpath "D:\ Program Files\mongodb\data\replica\data\r0 "--logpath" D:\Program files\mongodb\data\replica\log\r0.log "-- Logappendmongod.exe --replset rs1--keyfile "D:\Program files\mongodb\data\replica\key\r1"--port 28011--dbpath " D:\Program files\mongodb\data\replica\data\r1 "--logpath" D:\Program files\mongodb\data\replica\log\r1.log "-- logappendcd/d D:\Program files\mongodb\binmongod.exe --replset rs1--keyfile "D:\Program files\mongodb\data\ Replica\key\r2 "--port 28012--dbpath" D:\Program files\mongodb\data\replica\data\r2 "--logpath" D:\Program Files\ Mongodb\data\replica\log\r2.log "--logappend
Third, login client, initialize replica sets environment
"MongoDB" Windows platform builds MONGO database replica set (cluster-like)