Sharding Config Schema

Sharding configuration schema. This lives in the config servers.

Collections

version

This is a singleton that contains the current meta-data version number.

> db.getCollection("version").findOne()
{ "_id" : 1, "version" : 3 }
settings

Key/Value table for configurable options (chunkSize/balancer)

> db.settings.find()
{ "_id" : "chunksize", "value" : 64 }
{ "_id" : "balancer", "stopped" : false } //you can stop the balancer
shards

Stores information about the shards (possibly replicasets in rsname/list-of-host:port,... ). The addshard command creates these documents, and mongos processes periodically update the seed lists as the replica sets evolve over time.

> db.shards.findOne()
{ "_id" : "shard0", "host" : "localhost:30001" }
{ "_id" : "shard1", "host" : "shard1/localhost:30002" } //shard1 is a replicaset (think of this as a seed list)
databases
{ 
  "_id" : "admin", 
  "partitioned" : false, 
  "primary" : "shard0" 
}
collections

Stores meta information about each sharded collection. One entry per sharded collection.

mongos> db.collections.find()
{ 
  "_id" : "test.foo", 
  "lastmod" : ISODate("1970-01-16T04:42:21.124Z"), 
  "dropped" : false, 
  "key" : { "_id" : 1 }, 
  "unique" : false 
}
chunks
{
	"_id" : "test.foo-x_MinKey",
	"lastmod" : {
		"t" : 1271946858000,
		"i" : 1
	},
	"ns" : "test.foo",
	"min" : {
		"x" : { $minKey : 1 }
	},
	"max" : {
		"x" : { $maxKey : 1 }
	},
	"shard" : "shard0"
}
mongos

Record of all mongos affiliated with this cluster. mongos will ping every 30 seconds so we know who is alive. This is not used by the system for anything other than reporting.

> db.mongos.findOne()
{
	"_id" : "erh-wd1:27017",
	"ping" : "Fri Apr 23 2010 11:08:39 GMT-0400 (EST)",
	"up" : 30
}

changelog

Human readable log of all meta-data changes. Capped collection that defaults to 10mb.

> db.changelog.findOne()
{
	"_id" : "erh-wd1-2010-3-21-17-24-0",
	"server" : "erh-wd1",
	"time" : "Wed Apr 21 2010 13:24:24 GMT-0400 (EST)",
	"what" : "split",
	"ns" : "test.foo",
	"details" : {
		"before" : {
			"min" : {
				"x" : { $minKey : 1 }
			},
			"max" : {
				"x" : { $maxKey : 1 }
			}
		},
		"left" : {
			"min" : {
				"x" : { $minKey : 1 }
			},
			"max" : {
				"x" : 5
			}
		},
		"right" : {
			"min" : {
				"x" : 5
			},
			"max" : {
				"x" : { $maxKey : 1 }
			}
		}
	}
}

Changes

2 (<= 1.5.0) -> 3 (1.5.1)

  • shards : _id is now the name
  • databases : _id is now the db name
  • general : all references to a shard can be via name or host

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

PLEASE POST QUESTIONS IN THE FORUMS: http://groups.google.com/group/mongodb-user. Post tips and clarifications here.

blog comments powered by Disqus