mongodb sharding config数据库集合介绍

集群的嗦哦有的配置信息都保存在配置服务器上的config数据的集合中,可以直接访问该数据库,不过shell提供了一些辅助函数,通过这些函数更适合阅读信息,不过你还是可以通过查询config数据库的方式来获取集群的元数据.
总的来说,不应该直接修改config数据库里的任何数据,特殊情况除外,如果修改的数据,一般要重启所有的mongos服务器才能看到效果.

1.config.shards

shards集合记录了集合内的所有分片信息.
   
   
mongos> db.shards.find()
{ "_id" : "shard0000", "host" : "mongodb2:27017", "tags" : [ ] }
{ "_id" : "shard0001", "host" : "mongodb3:27017" }

2.config.databases

databases集合跟踪了集群内所有的数据库信息,不管有没有分片
   
   
mongos> db.databases.find()
{ "_id" : "test", "primary" : "shard0000", "partitioned" : true }
{ "_id" : "suq", "primary" : "shard0001", "partitioned" : false }
如果在数据库上开启了分片即执行了enableSharding,那么此处的partitioned为true.primary是database的主分片,数据库的新集合默认被创建在此分片上.

3.config.collections

collections集合记录所有分片集合的信息:
   
   
mongos> db.collections.find().pretty()
{
"_id" : "test.users",
"lastmodEpoch" : ObjectId("57693855f43b00b3956fed50"),
"lastmod" : ISODate("1970-02-19T17:02:47.296Z"),
"dropped" : false,
"key" : {
"i" : 1,
"username" : 1
},
"unique" : false,
"noBalance" : false
}
其中:
_id:是集合的命名空间
key:是片键
unique:表示片键是否是唯一索引

4.config.chunks

chunks集合记录了集合中所有块的信息.
   
   
mongos> db.chunks.findOne()
{
"_id" : "test.users-i_MinKeyusername_MinKey",
"lastmod" : Timestamp(28, 0),
"lastmodEpoch" : ObjectId("57693855f43b00b3956fed50"),
"ns" : "test.users",
"min" : {
"i" : { "$minKey" : 1 },
"username" : { "$minKey" : 1 }
},
"max" : {
"i" : 1,
"username" : "user1"
},
"shard" : "shard0001"
}
其中:
_id:块的唯一标识,通常有命名kongj,片键和块的下边界组合
ns:块所属的命名空间
min:块的最小值
max:块的最大值
shard:所属的分片.

5.config.changelog

changelog集合用于跟踪记录集群的操作.该集合会记录所有的拆分和迁移操作.
   
   
mongos> db.changelog.find({"_id":"mongodb2-2016-06-21T20:58:36.881+0800-576939fc0ad1e00c69efc8ac"}).pretty()
{
"_id" : "mongodb2-2016-06-21T20:58:36.881+0800-576939fc0ad1e00c69efc8ac",
"server" : "mongodb2",
"clientAddr" : "192.168.56.81:59114",
"time" : ISODate("2016-06-21T12:58:36.881Z"),
"what" : "multi-split",
"ns" : "test.users",
"details" : {
"before" : {
"min" : {
"i" : { "$minKey" : 1 },
"username" : { "$minKey" : 1 }
},
"max" : {
"i" : { "$maxKey" : 1 },
"username" : { "$maxKey" : 1 }
}
},
"number" : 1,
"of" : 15,
"chunk" : {
"min" : {
"i" : { "$minKey" : 1 },
"username" : { "$minKey" : 1 }
},
"max" : {
"i" : 1,
"username" : "user1"
},
"lastmod" : Timestamp(1, 1),
"lastmodEpoch" : ObjectId("57693855f43b00b3956fed50")
}
}
}
从details字段中可以看到文档在拆分前和拆分后的内容.

6.config.tags

tags集合在创建标签的时候发生,每个标签都与一个块范围相关联.
   
   
mongos> db.tags.find().pretty()
{
"_id" : {
"ns" : "test.users",
"min" : {
"i" : 50072,
"username" : "user50072"
}
},
"ns" : "test.users",
"min" : {
"i" : 50072,
"username" : "user50072"
},
"max" : {
"i" : 100048,
"username" : "user100048"
},
"tag" : "first"
}

7.config.settings

该集合包含了当前均衡器设置和块大小的文档信息
   
   
mongos> db.settings.find()
{ "_id" : "chunksize", "value" : NumberLong(64) }
{ "_id" : "balancer", "stopped" : false }















  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值