mongodb的分片(多字段),分片分裂原理

来源:互联网 发布:求一些莆田鞋的淘宝店 编辑:程序博客网 时间:2024/05/28 03:02
#指定集合中分片的片键,这里指定为id,time字段。

mongos> db.runCommand({shardcollection:"test.log",key:{id:1,time:1}})
{ "collectionsharded" : "test.log", "ok" : 1 }


b)         配置服务器(Config Server)。它存储了所有Shard节点的配置信息,每个chunk的Shard key范围,chunk在各Shard的分布情况以及集群中所有DB和collection的Shard配置信息。


详细请阅读 官方 mongodb 文档的 shard 一章 ,看官方文档总是最好的.因为是最全的.

Chunks 翻译下这章节

   MongoDB 的分区会被放入到 chunks 中. 每个 chunk 都有一个基于shard key的最小值(包含)和最大值(不包含) . MongoDB 会通过分片均衡模块(sharded cluster balancer)迁移 chunks.

See Data Partitioning with Chunks for more information.

sharding-shard-key/#choosing-a-shard-key

1. 范围策略 和 hbase 的分片和分裂是一样的.
   要求不能单调增长
2.dbproxy 策略. 对单调性无要求.
但是要求 基数大, 某个值低频.

https://docs.mongodb.com/manual/core/sharded-cluster-requirements/

原创粉丝点击