Question

I am trying to shard MongoDB. I am done with Sharding configuration, but I am not sure how to verify if sharding is functional.

How do i check whether my data is get sharded? Is there a query to verify/validate the shards?

Was it helpful?

Solution

MongoDB has detailed documentation on Sharding here ...

http://www.mongodb.org/display/DOCS/Sharding+Introduction

To anwser you question (I think), see the portion on the config Servers ...

Each config server has a complete copy of all chunk information. A two-phase commit is used to ensure the consistency of the configuration data among the config servers.

Basically, it is the config server's job to make sure everything get sharded ... correctly.

Also, there are system collections you can query ...

db.runCommand( { listshards : 1 } );

Lots of help in the prez below too ...

http://www.slideshare.net/mongodb/mongodb-sharding-internals

http://www.10gen.com/video/mongosv2010/sharding

OTHER TIPS

You can also execute a simple command on your mongos router :

> use admin
> db.printShardingStatus();

which should output informations about your shards, your sharded dbs and your sharded collection as mentioned in the mongodb documentation

sharding version: { "_id" : 1, "version" : 2 }
  shards:
      { "_id" : ObjectId("4bd9ae3e0a2e26420e556876"), "host" : "localhost:30001" }
      { "_id" : ObjectId("4bd9ae420a2e26420e556877"), "host" : "localhost:30002" }
      { "_id" : ObjectId("4bd9ae460a2e26420e556878"), "host" : "localhost:30003" }

  databases:
    { "name" : "admin", "partitioned" : false,
          "primary" : "localhost:20001",
          "_id" : ObjectId("4bd9add2c0302e394c6844b6") }
    my chunks

        { "name" : "foo", "partitioned" : true,
          "primary" : "localhost:30002",
          "sharded" : { "foo.foo" : { "key" : { "_id" : 1 }, "unique" : false } },
          "_id" : ObjectId("4bd9ae60c0302e394c6844b7") }
        my chunks
        foo.foo { "_id" : { $minKey : 1 } } -->> { "_id" : { $maxKey : 1 } }
                  on : localhost:30002 { "t" : 1272557259000, "i" : 1 }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top