Replicationset is used to avoid data loss on a single node. The test results are as follows: 228 million data records are inserted on the server. Disconnect the 162 service after the insertion is complete.
Replication set is used to avoid data loss on a single node. The test results are as follows: 228 million data records are inserted on the server. Disconnect the 162 service after the insertion is complete.
First, create a MongoDB design drawing for testing:
The figure is clear. Can take my other notes: Leave a message if you are not clear about it :)
Used hereReplication set to avoid data loss on a single node.
The test results are as follows:
Insert 228 million data records on the server. After the insertion is complete, the 162 server is disconnected and then executed in mongos quickly.
If an exception is thrown, run db. users. count ()
> Db. users. count ()
10000000
It is found that it is normal. 163 is changed to Primary.
Then, continue to insert 163 million data, and disconnect the server when the insertion process is interrupted.
The insert operation is normal. After the insertion, we compare the data of the following 164 servers + the data on the 162 servers connected is exactly equal to 2000.
After the two servers are connected again, the data keeps changing and load balancing is ongoing.
NOTE: If an instant power failure occurs in the data center, the data may still be faulty, but this probability is very small.