Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8457915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:56:09+00:00 2026-06-10T12:56:09+00:00

I am Trying to implement sharding on our mongoDB data base , Here is

  • 0

I am Trying to implement sharding on our mongoDB data base , Here is the scenario

we have 1 server running config server

we have 2 servers running mongod instances called node1 and node2

We have 1 server running mongos

I have added the servers node1 and node2 as shard servers in the mongos shell by using the command

db.runCommand( { addshard : “serverhostname[:port]” } );

later I created database in node1 and enabled sharding for that database from Mongos

Now we have 2 shard servers and as per MongoDB documentation mongos should put some collections which are created node1 ( where the database actually resides ) and some collections on node 2 .

I created 300 collections from mongos but still all collections are going to only one server what is wrong in the above mentioned support

NOTE : – Since I am not in a position to upgrade the application layer I cant shard in collection level , I have a script which creates several collections dynamically for some requirement .

Please Provide your suggestions on how we can shard in database level so that collections gets equally distributed among all shard servers .

I am looking for some solution like

IF i create 300 collections automatically mongos should create around 150 or 100 collections in each of the two sharded servers .

Thanks in advance for stepping in and helping me fix this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:56:11+00:00Added an answer on June 10, 2026 at 12:56 pm

    Collections are not automatically distributed across shards until you enable sharding on them and then add data. Those sharded collections will then have data on both shards (split into chunks and balanced automatically).

    Until you actually run the command on the collections, and have enough data in them so that they start splitting and migrating chunks, then they will all stay where they are.

    That is because each database has a primary shard, which does not change. That is where the database will be created initially and where all of its non-sharded data will live. If you add another database, the mongos should create it on the second shard and alternate (or round robin if more than two) for each created database. In each case, until you shard the collection, it will stay solely on the primary shard for that database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to implement a search similar to here .This searches properties based on city,locality,property
Found a really nice code for Accordion nav and am trying implement on our
Trying to implement the signature verification of inapp billing on my server (Django/Python). I
I'm trying implement Data Annotation to my Linq to SQL objects. The .dbml file
I have this weird kind of error. I am trying implement basic Euclidean algorithm
Trying to implement what I thought was a simple concept. I have a user
Trying to implement AVAudioplayer and get some metering data of the played music, but
Trying to implement the example from here. Facebook Share passes along the URL of
I have a VB Solution with a dozen forms trying to implement invoice system.
I am trying implement the Data transformation using Reflection 1 example in my code.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.