【问题标题】:Redundant chunk in mongo shardmongo 分片中的冗余块
【发布时间】: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 的任何文档,它现在可能不是空的。

标签: mongodb sharding


【解决方案1】:

看起来你有一个空的第一个块。 来自 MongoDB 文档:如果块没有与其分片键范围关联的文档,则该块为空。

重要 空块可以使平衡器在未平衡时将集群评估为适当平衡。 空块可能在各种情况下出现,包括:

如果预拆分创建了太多块,则数据到块的分布可能不均匀。 如果您从分片集合中删除许多文档,则某些块可能不再包含数据。

您的问题是在同一个分片上没有可以合并的连续块(​​空+非空)。所以现在你将不得不忍受它。 请参考以下链接: Merge chunks in sharded cluster

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-25
    • 1970-01-01
    • 1970-01-01
    • 2021-08-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多