Sharding Administration

See also Configuring.

> // test if we are speaking to a mongos process or 
> // straight to a mongod process
> db.$cmd.findOne({isdbgrid:1});

> // mongos returns { ismaster: 0.0, msg: "isdbgrid" }
> db.$cmd.findOne({ismaster:1});

List Existing Shards

> db.runCommand( { listshards : 1 } )
{"servers" :
 [{"_id" :  ObjectId( "4a9d40c981ba1487ccfaa634")  ,
   "host" : "localhost:10000"},
  {"_id" :  ObjectId( "4a9d40df81ba1487ccfaa635")  ,
   "host" : "localhost:10001"}
 ],
 "ok" : 1
}

List Which Databases are Sharded

Here we query the config database (through mongos – your shell connection is connected to a mongos and it connects to the config database automatically).

> config = db.getSisterDB("config")
> config.system.namespaces.find()

See full sharding setup

> printShardingStatus( db.getSisterDB( "config" ) );

Moving a chunk manually

has to be run on admin db

db.runCommand( { movechunk : <full ns> , find : <something in the chunk> , to : <shard name> } )

example:

db.runCommand( { movechunk : "test.blog.posts" , find : { title : "The Cool Post" } , to : "192.168.1.2" } )

More

> db.runCommand({netstat:1})
implementation pending...

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

IF YOU HAVE A QUESTION, POST IT TO THE USER GROUP.

These pages are fine for comments, but for questions, your best bet will always be the MongoDB User Group.

blog comments powered by Disqus