top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

MongoDB Sharding: data is saving in primary shard only

0 votes
284 views

I have implemented sharding for two collections based on a column which is not indexed. Now after checking sh.status(), I can see all the data is saving in primary shard only. Data is not distributing among the other shard servers. What to do?

posted May 6, 2016 by Amit Parthsarthi

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

As written in mongodb docs "To shard a collection, you need to select a shard key. A shard key is either an indexed field or an indexed compound field that exists in every document in the collection. MongoDB divides the shard key values into chunks and distributes the chunks evenly across the shards. To divide the shard key values into chunks, MongoDB uses either range based partitioning or hash based partitioning" you can't solve your problem without indexing it. so create an indexed field first then check status of sh.status() .
Reference: https://docs.mongodb.com/manual/reference/method/sh.status/ &
https://docs.mongodb.com/manual/core/sharding-introduction/

answer May 23, 2016 by Shivam Kumar Pandey
Similar Questions
+1 vote

Minimum on what data size Sharding is recommended in MongoDB? Suppose my database size is 1 GB is sharding necessary? if I do not create shard will that work for me, for this data size.

+1 vote

Does anyone know how I remove orphaned documents in a cluster (sharding) in mongodb version 3.0.10, My actual data are 20 million orphans and documents the value amounts to 21 million data

0 votes

some same cases data is not important, and replicate them from primary to secondary will waste servers performance. Is there any ways to config?

...