Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB Replica Set: Disk size difference in Primary and Secondary Nodes

I just did the mongodb replica set configuration and all looks good. All data moved to secondary nodes properly. But when I looked at the data directory, I can see Primary have ~140G of data and at the same time secondary has only ~110G.

Did anyone come across this kind of issue while setting up the Replica Set. Is that something normal behavior?

like image 663
geek Avatar asked Feb 12 '13 22:02

geek


People also ask

What are primary and secondary replica sets in MongoDB?

A replica set is a group of mongod instances that maintain the same data set. A replica set contains several data bearing nodes and optionally one arbiter node. Of the data bearing nodes, one and only one member is deemed the primary node, while the other nodes are deemed secondary nodes.

What is the limitation of single replica set in MongoDB?

A replica set can have up to 7 voting members. If you have an even number of voting members, deploy another data bearing voting member or, if constraints prohibit against another data bearing voting member, an arbiter.

How many primary nodes are there in a replica set?

Replica set can have only one primary node. Replica set is a group of two or more nodes (generally minimum 3 nodes are required). In a replica set, one node is primary node and remaining nodes are secondary.

What is the maximum number of nodes in MongoDB replica set?

MongoDB supports replica sets, which can have up to 50 nodes.


1 Answers

When you do an initial sync from scratch on a secondary, it writes all the data fresh. This removes padding, empty space (deleted data) etc. As a result, in that respect it is similar to running a repair.

If you ran a repair on the primary (blocking operation, only to be done if absolutely necessary), then the two would be far closer overall.

If you check the output from db.stats() you should see that the various databases have the same object count, the data directory size differences are nothing to be worried about.

like image 91
Adam Comerford Avatar answered Nov 02 '22 12:11

Adam Comerford