shard 集群的系统信息也是保留在config数据库的集合里面的。
本文介绍一些Shard 的配置信息查询,
mongos> use config
switched to db config
查询当前的版本
mongos> db.getCollection("version").findOne()
{ "_id" : 1, "version" : 3 }
查询当前的配置chunkSize的大小
mongos> db.settings.find()
{ "_id" : "chunksize", "value" : 1 }
查询整个shard集群的成员
mongos> db.shards.find()
{ "_id" : "shard0000", "host" : "10.250.7.225:27018" }
{ "_id" : "shard0001", "host" : "10.250.7.249:27019" }
{ "_id" : "shard0002", "host" : "10.250.7.241:27020" }
查询被水平拆分的集合:
mongos> db.collections.find()
{ "_id" : "test.yql", "lastmod" : ISODate("1970-01-16T06:45:27.212Z"), "dropped" : false, "key" : { "_id" : 1 }, "unique" : true }
查询被水平拆分的集合分成的chunk分布
mongos> db.chunks.find()
{ "_id" : "test.yql-_id_MinKey", "lastmod" : { "t" : 2000, "i" : 1 }, "ns" : "test.yql", "min" : { "_id" : { $minKey : 1 } }, "max" : { "_id" : ObjectId("4eb298b3adbd9673afee95e3") }, "shard" : "shard0000" }
{ "_id" : "test.yql-_id_ObjectId('4eb298b3adbd9673afee95e3')", "lastmod" : { "t" : 1000, "i" : 3 }, "ns" : "test.yql", "min" : { "_id" : ObjectId("4eb298b3adbd9673afee95e3") }, "max" : { "_id" : ObjectId("4eb2a64640643e5bb60072f7") }, "shard" : "shard0000" }
{ "_id" : "test.yql-_id_ObjectId('4eb2a64640643e5bb60072f7')", "lastmod" : { "t" : 3000, "i" : 1 }, "ns" : "test.yql", "min" : { "_id" : ObjectId("4eb2a64640643e5bb60072f7") }, "max" : { "_id" : ObjectId("4eb2a65340643e5bb600e084") }, "shard" : "shard0002" }
{ "_id" : "test.yql-_id_ObjectId('4eb2a65340643e5bb600e084')", "lastmod" : { "t" : 3000, "i" : 0 }, "ns" : "test.yql", "min" : { "_id" : ObjectId("4eb2a65340643e5bb600e084") }, "max" : { "_id" : { $maxKey : 1 } }, "shard" : "shard0001" }
查询当前mongodb里面的数据库的shard信息:
mongos> db.databases.find()
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "test", "partitioned" : true, "primary" : "shard0000" }
{ "_id" : "mongos", "partitioned" : false, "primary" : "shard0000" }
mongos集合记录的这个集群中的所有mongos服务,默认每隔30s钟ping mongos服务器一次,以便查看其是否alive。
mongos> db.mongos.find()
{ "_id" : "rac4:27017", "ping" : ISODate("2011-11-05T05:47:50.575Z"), "up" : 145503 }
changlog 集合
记录了sharding 集群的元数据,changlog 默认记录10M的操作。
mongos> db.changelog.findOne()
{
"_id" : "rac1-2011-11-03T14:42:14-0",
"server" : "rac1",
"clientAddr" : "10.250.7.220:53899",
"time" : ISODate("2011-11-03T14:42:14.873Z"),
"what" : "split",
"ns" : "test.yql",
"details" : {
"before" : {
"min" : {
"_id" : { $minKey : 1 }
},
"max" : {
"_id" : { $maxKey : 1 }
},
"lastmod" : {
"t" : 1000,
"i" : 0
}
},
"left" : {
"min" : {
"_id" : { $minKey : 1 }
},
"max" : {
"_id" : ObjectId("4eb298b3adbd9673afee95e3")
},
"lastmod" : {
"t" : 1000,
"i" : 1
}
},
"right" : {
"min" : {
"_id" : ObjectId("4eb298b3adbd9673afee95e3")
},
"max" : {
"_id" : { $maxKey : 1 }
},
"lastmod" : {
"t" : 1000,
"i" : 2
}
}
}
}
mongos> db.changelog.find()
{ "_id" : "rac1-2011-11-03T14:42:14-0", "server" : "rac1", "clientAddr" : "10.250.7.220:53899", "time" : ISODate("2011-11-03T14:42:14.873Z"), "what" : "split", "ns" : "test.yql", "details" : { "before" : { "min" : { "_id" : { $minKey : 1 } }, "max" : { "_id" : { $maxKey : 1 } }, "lastmod" : { "t" : 1000, "i" : 0 } }, "left" : { "min" : { "_id" : { $minKey : 1 } }, "max" : { "_id" : ObjectId("4eb298b3adbd9673afee95e3") }, "lastmod" : { "t" : 1000, "i" : 1 } }, "right" : { "min" : { "_id" : ObjectId("4eb298b3adbd9673afee95e3") }, "max" : { "_id" : { $maxKey : 1 } }, "lastmod" : { "t" : 1000, "i" : 2 } } } }
{ "_id" : "rac1-2011-11-03T14:42:16-1", "server" : "rac1", "clientAddr" : "10.250.7.220:53899", "time" : ISODate("2011-11-03T14:42:16.294Z"), "what" : "split", "ns" : "test.yql", "details" : { "before" : { "min" : { "_id" : ObjectId("4eb298b3adbd9673afee95e3") }, "max" : { "_id" : { $maxKey : 1 } }, "lastmod" : { "t" : 1000, "i" : 2 } }, "left" : { "min" : { "_id" : ObjectId("4eb298b3adbd9673afee95e3") }, "max" : { "_id" : ObjectId("4eb2a64640643e5bb60072f7") }, "lastmod" : { "t" : 1000, "i" : 3 } }, "right" : { "min" : { "_id" : ObjectId("4eb2a64640643e5bb60072f7") }, "max" : { "_id" : { $maxKey : 1 } }, "lastmod" : { "t" : 1000, "i" : 4 } } } }
{ "_id" : "rac1-2011-11-03T14:42:16-2", "server" : "rac1", "clientAddr" : "10.250.7.220:53899", "time" : ISODate("2011-11-03T14:42:16.460Z"), "what" : "moveChunk.start", "ns" : "test.yql", "details" : { "min" : { "_id" : ObjectId("4eb2a64640643e5bb60072f7") }, "max" : { "_id" : { $maxKey : 1 } }, "from" : "shard0000", "to" : "shard0002" } }
{ "_id" : "rac1-2011-11-03T14:42:21-3", "server" : "rac1", "clientAddr" : "10.250.7.220:53899", "time" : ISODate("2011-11-03T14:42:21.544Z"), "what" : "moveChunk.commit", "ns" : "test.yql", "details" : { "min" : { "_id" : ObjectId("4eb2a64640643e5bb60072f7") }, "max" : { "_id" : { $maxKey : 1 } }, "from" : "shard0000", "to" : "shard0002" } }
{ "_id" : "rac3-2011-11-03T14:42:21-0", "server" : "rac3", "clientAddr" : "", "time" : ISODate("2011-11-03T14:42:21.513Z"), "what" : "moveChunk.to", "ns" : "test.yql", "details" : { "min" : { "_id" : ObjectId("4eb2a64640643e5bb60072f7") }, "max" : { "_id" : { $maxKey : 1 } }, "step1" : 3604, "step2" : 982, "step3" : 1, "step4" : 0, "step5" : 423 } }
{ "_id" : "rac1-2011-11-03T14:42:21-4", "server" : "rac1", "clientAddr" : "10.250.7.220:53899", "time" : ISODate("2011-11-03T14:42:21.686Z"), "what" : "moveChunk.from", "ns" : "test.yql", "details" : { "min" : { "_id" : ObjectId("4eb2a64640643e5bb60072f7") }, "max" : { "_id" : { $maxKey : 1 } }, "step1" : 0, "step2" : 121, "step3" : 8, "step4" : 5005, "step5" : 69, "step6" : 29 } }
{ "_id" : "rac3-2011-11-03T14:42:29-1", "server" : "rac3", "clientAddr" : "10.250.7.220:11131", "time" : ISODate("2011-11-03T14:42:29.819Z"), "what" : "split", "ns" : "test.yql", "details" : { "before" : { "min" : { "_id" : ObjectId("4eb2a64640643e5bb60072f7") }, "max" : { "_id" : { $maxKey : 1 } }, "lastmod" : { "t" : 2000, "i" : 0 } }, "left" : { "min" : { "_id" : ObjectId("4eb2a64640643e5bb60072f7") }, "max" : { "_id" : ObjectId("4eb2a65340643e5bb600e084") }, "lastmod" : { "t" : 2000, "i" : 2 } }, "right" : { "min" : { "_id" : ObjectId("4eb2a65340643e5bb600e084") }, "max" : { "_id" : { $maxKey : 1 } }, "lastmod" : { "t" : 2000, "i" : 3 } } } }
{ "_id" : "rac3-2011-11-03T14:42:30-2", "server" : "rac3", "clientAddr" : "10.250.7.220:11131", "time" : ISODate("2011-11-03T14:42:30.103Z"), "what" : "moveChunk.start", "ns" : "test.yql", "details" : { "min" : { "_id" : ObjectId("4eb2a65340643e5bb600e084") }, "max" : { "_id" : { $maxKey : 1 } }, "from" : "shard0002", "to" : "shard0001" } }
{ "_id" : "rac3-2011-11-03T14:44:15-3", "server" : "rac3", "clientAddr" : "10.250.7.220:11131", "time" : ISODate("2011-11-03T14:44:15.246Z"), "what" : "moveChunk.commit", "ns" : "test.yql", "details" : { "min" : { "_id" : ObjectId("4eb2a65340643e5bb600e084") }, "max" : { "_id" : { $maxKey : 1 } }, "from" : "shard0002", "to" : "shard0001" } }
{ "_id" : "rac3-2011-11-03T14:44:15-4", "server" : "rac3", "clientAddr" : "10.250.7.220:11131", "time" : ISODate("2011-11-03T14:44:15.389Z"), "what" : "moveChunk.from", "ns" : "test.yql", "details" : { "min" : { "_id" : ObjectId("4eb2a65340643e5bb600e084") }, "max" : { "_id" : { $maxKey : 1 } }, "step1" : 0, "step2" : 204, "step3" : 100023, "step4" : 5007, "step5" : 111, "step6" : 0 } }
mongos>