【发布时间】:2014-07-29 14:19:03
【问题描述】:
我正在本地机器上测试 mongodb 分片。一切似乎都运行良好,除了我的第一个块是多余的。 我最初运行了一个 mongod 实例,它有 100,000 个这样的条目,
{ "_id" : ObjectId("53d788d26d664906cb359203"), "ind" : 123, "123" : 123, "someThing" : 5656 }.
我已经在'ind' 上索引了这个实例。所以,基本上有十万个条目,ind 在 0 到 100000 的范围内。
在整个分片部署之后。
我在我的 mongos 实例上运行 sh.status() 我得到了这个。
--- Sharding Status--
sharding version: {
"_id" : 1,
"version" : 4,
"minCompatibleVersion" : 4,
"currentVersion" : 5,
"clusterId" : ObjectId("53d74302e7df70cc9b8394e3")
}
shards:
{ "_id" : "shard0000", "host" : "localhost:104" }
{ "_id" : "shard0001", "host" : "localhost:105" }
{ "_id" : "shard0002", "host" : "localhost:106" }
databases:
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "test", "partitioned" : true, "primary" : "shard0000" }
test.data
shard key: { "ind" : 1 }
chunks:
shard0001 1
shard0002 2
shard0000 1
{ "ind" : { "$minKey" : 1 } } -->> { "ind" : 0 } on : shard0001 Timestamp(2, 0)
{ "ind" : 0 } -->> { "ind" : 25000 } on : shard0002 Timestamp(3, 2)
{ "ind" : 25000 } -->> { "ind" : 50000 } on : shard0002 Timestamp(3, 3)
{ "ind" : 50000 } -->> { "ind" : { "$maxKey" : 1 } } on : shard0000 Timestamp(3, 1)
这是我最初的状态。添加一些数据后:
--- Sharding Status ---
sharding version: {
"_id" : 1,
"version" : 4,
"minCompatibleVersion" : 4,
"currentVersion" : 5,
"clusterId" : ObjectId("53d74302e7df70cc9b8394e3")
}
shards:
{ "_id" : "shard0000", "host" : "localhost:104" }
{ "_id" : "shard0001", "host" : "localhost:105" }
{ "_id" : "shard0002", "host" : "localhost:106" }
databases:
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "test", "partitioned" : true, "primary" : "shard0000" }
test.data
shard key: { "ind" : 1 }
chunks:
shard0001 4
shard0002 4
shard0000 4
{ "ind" : { "$minKey" : 1 } } -->> { "ind" : 0 } on : shard0001 Timestamp(2, 0)
{ "ind" : 0 } -->> { "ind" : 25000 } on : shard0002 Timestamp(3, 2)
{ "ind" : 25000 } -->> { "ind" : 50000 } on : shard0002 Timestamp(3, 3)
{ "ind" : 50000 } -->> { "ind" : 87449 } on : shard0001 Timestamp(4, 0)
{ "ind" : 87449 } -->> { "ind" : 149796 } on : shard0001 Timestamp(5, 0)
{ "ind" : 149796 } -->> { "ind" : 224694 } on : shard0002 Timestamp(6, 0)
{ "ind" : 224694 } -->> { "ind" : 299592 } on : shard0001 Timestamp(7, 0)
{ "ind" : 299592 } -->> { "ind" : 374490 } on : shard0002 Timestamp(8, 0)
{ "ind" : 374490 } -->> { "ind" : 524286 } on : shard0000 Timestamp(8, 1)
{ "ind" : 524286 } -->> { "ind" : 674082 } on : shard0000 Timestamp(7, 2)
{ "ind" : 674082 } -->> { "ind" : 992211 } on : shard0000 Timestamp(7, 3) { "ind" : 992211 } -->> { "ind" : { "$maxKey" : 1 } } on : shard0000 Timestamp(3,5)
我的分片键也是ind。
但是"ind" : { "$minKey" : 1 } } -->> { "ind" : 0 } on : shard0001 Timestamp(2, 0)
显然是不对的`。
我的第一个块永远是空的。
我该怎么办?
【问题讨论】:
-
您能澄清一下问题所在吗?第一个块并不总是空的。您可以使用
ind < 0添加文档。如果您添加了带有ind < 0的任何文档,它现在可能不是空的。