首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有标签感知切分的Mongodb复合碎片密钥

带有标签感知切分的Mongodb复合碎片密钥
EN

Stack Overflow用户
提问于 2016-02-18 15:20:59
回答 1查看 114关注 0票数 1

Mongodb复合碎片键与标签感知切分。

环境

  • 我有一个包含4个碎片的mongodb集群。
  • 前两个碎片有一个Americas的国家标记,最后两个碎片有一个Europe标记。
  • shard键在字段country, user, domain上是复合的。

问题

我正在尝试基于国家的标签感知切分,所以任何带有country: 1的文档都将在前两个切分之间自动切分,而任何带有country: 2的文档都将自动切分到最后两个切分。

代码语言:javascript
复制
Sample Data:`
"_id" : ObjectId("56c4cc2fb086de4769800fe4"), "timestamp" : ISODate("1970-01-01T00:00:00Z"), "user" : "guest", "category" : "Google", "domain" : "google.com", "source" : 1.1.1.1, "destination" : 2.2.2.2, "country" : 1, "__v" : 0`
"_id" : ObjectId("56c4cc2fb086de4769800fe4"), "timestamp" : ISODate("1970-01-01T00:00:00Z"), "user" : "guest2", "category" : "Bing", "domain" : "bing.com", "source" : 2.2.2.2, "destination" : 3.3.3.3, "country" : 2, "__v" : 0`

config.tags:
"_id" : { "ns" : "logs.sitea", "min" : { "country" : "1" } }, "ns" : "logs.sitea", "min" : { "country" : "1" }, "max" : { "country" : "2" }, "tag" : "Americas"`
"_id" : { "ns" : "logs.siteb", "min" : { "country" : "2" } }, "ns" : "logs.siteb", "min" : { "country" : "2" }, "max" : { "country" : "3" }, "tag" : "Europe"`

config.shards:
"_id" : "shard0000", "host" : "1.1.1.1:27019", "tags" : [ "Americas" ]`
"_id" : "shard0001", "host" : "1.1.1.2:27019", "tags" : [ "Americas" ]`
"_id" : "shard0002", "host" : "2.2.2.2:27019", "tags" : [ "Europe" ]`
"_id" : "shard0003", "host" : "2.2.2.3:27019", "tags" : [ "Europe" ]`

sh.status:
"_id" : "logs",  "primary" : "shard0002",  "partitioned" : true`
            logs.sitea`
                    shard key: { "country" : 1, "user" : 1, "domain" : 1 }
                    unique: false`
                    balancing: true`
                    chunks:`
                    tag: Americas  { "country" : "1" } -->> { "country" : "2"`

"_id" : "logs",  "primary" : "shard0002",  "partitioned" : true }`
            logs.siteb`
                    shard key: { "country" : 1, "user" : 1, "domain" : 1 
                    unique: false`
                    balancing: true`
                    chunks:`
                    tag: Europe  { "country" : "2" } -->> { "country" : "3" }
EN

回答 1

Stack Overflow用户

发布于 2016-02-22 16:02:57

我的问题是关于国家代码的双引号。

更新标签解决了我的问题:"_id“:{ "ns”:"logs.sitea","min“:{ "country”:1 },"ns“:"logs.sitea","min”:{ "country“:1 },"max”:{ "country“:2 }," tag”:“America”

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35485435

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档