0

My structure:

A Sharded Cluster with multiple Shards. Each Shard contains 1 Collection, which is pinned to it by tags. Every Shard is at the same time a ReplicaSet Secondary. It receives data from a Replica Set server.

The situation:

A lot of PCs will push data into my database. I want to spread the load by using shards. Every PC will push only his own collection into my database and shall not know any data of other PCs. Every PC itself holds a MongoDB server. Sadly I can't ensure, that every PC will have connection to my Cluster all the time, so they have to store everything in their own database first, which is meant to replicate its content to my cluster, when the connection is stable again.

The goal:

Having a centralized big database on my end, which contains every PCs collection, without having a PC knowing any data from another PC.

enter image description here

The problem: I set up a Cluster with Shards and every Shard has got a Replica Set as Primary. Whenever a Replica Set pushes Data into the Shard (via standard replication), the Cluster sees only the database, that has been created by the Replica Set. Is there a way to let the Cluster know the data inside of the Shard? Or is there even a better way to handle this situation?

I'm free to use any version of MongoDB.

Thanks in advance!

Edit: Whenever my Cluster, the Shard and the Replica Set contain the same Collection, I get the error:

WriteResult({
        "nInserted" : 0,
        "writeError" : {
                "code" : 193,
                "errmsg" : "Cannot accept sharding commands if not started with --shardsvr"
        }
})

upon interacting with the collection from the Cluster (In this case I tried to write files from the Cluster to the collection).

  • Please edit your question to include the specific version of MongoDB server used and a description of how you are writing data to the shard replica set servers (via mongod or mongos). Your question could also be improved with a diagram of your sharded cluster components (config servers, shard mongod servers, and mongos) rather than an abstract diagram. All data access should be via a mongos instance and your replica set mongod servers should be started with --shardsvr (or the sharding.clusterRole config file equivalent). – Stennie Jan 14 at 20:43
  • Thank you very much for your answer! Actually your hint to using --shardsvr even for the replica set end nodes, helped me solving this problem. My cluster works now. – Calvin Jan 16 at 11:42

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.