我在MongoDB中遇到了一些麻煩。這是我的配置:MongoDB標記範圍不起作用
mongos> sh.status()
--- Sharding Status ---
sharding version: {
"_id" : 1,
"version" : 4,
"minCompatibleVersion" : 4,
"currentVersion" : 5,
"clusterId" : ObjectId("546f2d9c37d2895f3b8f9ec1")
}
shards:
{ "_id" : "site_A_shard_1", "host" : "site_A_shard_1/<HOST1>:27510,<HOST2>:27511", "tags" : [ "site_A" ] }
{ "_id" : "site_A_shard_2", "host" : "site_A_shard_2/<HOST2>:27521,<HOST1>:27520", "tags" : [ "site_A" ] }
{ "_id" : "site_B_shard_1", "host" : "site_B_shard_1/<HOST3>:27510,<HOST4>:27511", "tags" : [ "site_B" ] }
{ "_id" : "site_B_shard_2", "host" : "site_B_shard_2/<HOST4>:27521,<HOST3>:27520", "tags" : [ "site_B" ] }
databases:
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "test", "partitioned" : false, "primary" : "site_B_shard_1" }
{ "_id" : "ocs", "partitioned" : true, "primary" : "site_B_shard_1" }
ocs.adrs_queue
shard key: { "shard.target" : 1, "shard.key" : 1 }
{ "shard.target" : { "$minKey" : 1 }, "shard.key" : { "$minKey" : 1 } } -->> { "shard.target" : { "$maxKey" : 1 }, "shard.key" : { "$maxKey" : 1 } } on : site_B_shard_1 Timestamp(1, 0)
tag: site_A { "shard" : { "target" : "siteA", "key" : { "$minKey" : 1 } } } -->> { "shard" : { "target" : "siteA", "key" : { "$maxKey" : 1 } } }
tag: site_B { "shard" : { "target" : "siteB", "key" : { "$minKey" : 1 } } } -->> { "shard" : { "target" : "siteB", "key" : { "$maxKey" : 1 } } }
ocs.ldrs
shard key: { "shard.target" : 1, "shard.key" : 1 }
{ "shard.target" : { "$minKey" : 1 }, "shard.key" : { "$minKey" : 1 } } -->> { "shard.target" : { "$maxKey" : 1 }, "shard.key" : { "$maxKey" : 1 } } on : site_B_shard_1 Timestamp(1, 0)
tag: site_A { "shard" : { "target" : "siteA", "key" : { "$minKey" : 1 } } } -->> { "shard" : { "target" : "siteA", "key" : { "$maxKey" : 1 } } }
tag: site_B { "shard" : { "target" : "siteB", "key" : { "$minKey" : 1 } } } -->> { "shard" : { "target" : "siteB", "key" : { "$maxKey" : 1 } } }
ocs.notifs_queue
shard key: { "shard.target" : 1, "shard.key" : 1 }
{ "shard.target" : { "$minKey" : 1 }, "shard.key" : { "$minKey" : 1 } } -->> { "shard.target" : { "$maxKey" : 1 }, "shard.key" : { "$maxKey" : 1 } } on : site_B_shard_1 Timestamp(1, 0)
tag: site_A { "shard" : { "target" : "siteA", "key" : { "$minKey" : 1 } } } -->> { "shard" : { "target" : "siteA", "key" : { "$maxKey" : 1 } } }
tag: site_B { "shard" : { "target" : "siteB", "key" : { "$minKey" : 1 } } } -->> { "shard" : { "target" : "siteB", "key" : { "$maxKey" : 1 } } }
ocs.ss_queue
shard key: { "shard.target" : 1, "shard.key" : 1 }
{ "shard.target" : { "$minKey" : 1 }, "shard.key" : { "$minKey" : 1 } } -->> { "shard.target" : { "$maxKey" : 1 }, "shard.key" : { "$maxKey" : 1 } } on : site_B_shard_1 Timestamp(1, 0)
tag: site_A { "shard" : { "target" : "siteA", "key" : { "$minKey" : 1 } } } -->> { "shard" : { "target" : "siteA", "key" : { "$maxKey" : 1 } } }
tag: site_B { "shard" : { "target" : "siteB", "key" : { "$minKey" : 1 } } } -->> { "shard" : { "target" : "siteB", "key" : { "$maxKey" : 1 } } }
儘管配置了標籤範圍,但它似乎不起作用。每次嘗試插入一些信息時,即使關聯的標記爲site_A,它也會存儲在同一個分片(site_B_shard_1)中。
我在做什麼錯?