Mongo不均匀的碎片分布

时间:2014-07-28 13:53:38

标签: mongodb database nosql

最初我们的服务器以4个分片开始。在运行该站点几年之后,我们决定再添加4个分片以帮助减轻现有服务器的负载,现在问题是分片分布非常不均匀并且新服务器由于这个原因而没有帮助负载。以下是我们较大的集合之一的分片分发示例

Shard shard0000 contains 15.56% data, 15.56% docs in cluster, avg obj size on shard : 143B
Shard shard0001 contains 15.12% data, 15.12% docs in cluster, avg obj size on shard : 143B
Shard shard0002 contains 16.73% data, 16.73% docs in cluster, avg obj size on shard : 143B
Shard shard0003 contains 15.62% data, 15.62% docs in cluster, avg obj size on shard : 143B
Shard shard0004 contains 9.31% data, 9.31% docs in cluster, avg obj size on shard : 143B
Shard shard0005 contains 9.35% data, 9.35% docs in cluster, avg obj size on shard : 143B
Shard shard0006 contains 9.12% data, 9.12% docs in cluster, avg obj size on shard : 143B
Shard shard0007 contains 9.16% data, 9.16% docs in cluster, avg obj size on shard : 143B

平衡器在非高峰时段一直在运行,但它似乎并没有解决不均匀的分布。

有什么建议吗?

更新:添加了集合的sh.status()

    shard key: { "hash" : 1 }
    chunks:
        shard0004   21
        shard0007   20
        shard0006   20
        shard0005   21
        shard0002   24
        shard0003   24
        shard0001   24
        shard0000   25
    { "hash" : { "$minKey" : 1 } } -->> { "hash" : "0096c316a754c8f628793402d6a217fa" } on : shard0004 Timestamp(28, 0) 
    { "hash" : "0096c316a754c8f628793402d6a217fa" } -->> { "hash" : "01767732a77657e2e67e3b1d1afa6216" } on : shard0007 Timestamp(65, 0) 
    { "hash" : "01767732a77657e2e67e3b1d1afa6216" } -->> { "hash" : "0256566c72f3d75dff16b5740bf60df3" } on : shard0004 Timestamp(66, 0) 
    { "hash" : "0256566c72f3d75dff16b5740bf60df3" } -->> { "hash" : "0323ebd846f1897351bf904092492253" } on : shard0006 Timestamp(68, 0) 
    { "hash" : "0323ebd846f1897351bf904092492253" } -->> { "hash" : "03f0faf2bc0b91570816c1811b1bf89e" } on : shard0007 Timestamp(69, 0) 
    { "hash" : "03f0faf2bc0b91570816c1811b1bf89e" } -->> { "hash" : "04acc3c7bbfb66570601e88a498598ae" } on : shard0007 Timestamp(73, 0) 
    { "hash" : "04acc3c7bbfb66570601e88a498598ae" } -->> { "hash" : "056891c4103e62d7f6d90afc6bc0113c" } on : shard0004 Timestamp(74, 0) 
    { "hash" : "056891c4103e62d7f6d90afc6bc0113c" } -->> { "hash" : "06250a5a7c6d0985c1b0d975d005b216" } on : shard0005 Timestamp(75, 0) 
    { "hash" : "06250a5a7c6d0985c1b0d975d005b216" } -->> { "hash" : "06e17baaaf9c74bb4a94e80b8c5be56b" } on : shard0006 Timestamp(76, 0) 
    { "hash" : "06e17baaaf9c74bb4a94e80b8c5be56b" } -->> { "hash" : "079c56d507673f2a7a0f11aad27da3c7" } on : shard0005 Timestamp(79, 0) 
    { "hash" : "079c56d507673f2a7a0f11aad27da3c7" } -->> { "hash" : "08585cf98b8f1d5027ead5622d770e32" } on : shard0006 Timestamp(80, 0) 
    { "hash" : "08585cf98b8f1d5027ead5622d770e32" } -->> { "hash" : "091404f3a9faf42c75c1fe7ccd87c1ba" } on : shard0006 Timestamp(84, 0) 
    { "hash" : "091404f3a9faf42c75c1fe7ccd87c1ba" } -->> { "hash" : "09cfc86384d3b0ff5c4ed3ee8ecfda3d" } on : shard0004 Timestamp(86, 0) 
    { "hash" : "09cfc86384d3b0ff5c4ed3ee8ecfda3d" } -->> { "hash" : "0b0719d7022b9d6d831c4253dd9861ed" } on : shard0005 Timestamp(87, 0) 
    { "hash" : "0b0719d7022b9d6d831c4253dd9861ed" } -->> { "hash" : "0f601a06372d8874b4ff4dc58b9ac0e6" } on : shard0002 Timestamp(87, 1) 
    { "hash" : "0f601a06372d8874b4ff4dc58b9ac0e6" } -->> { "hash" : "10c7fb288ab4657d63c40df3cee5eec5" } on : shard0002 Timestamp(60, 16) 
    { "hash" : "10c7fb288ab4657d63c40df3cee5eec5" } -->> { "hash" : "121a5790eea9e48113dbf13bc920381c" } on : shard0002 Timestamp(71, 4) 
    { "hash" : "121a5790eea9e48113dbf13bc920381c" } -->> { "hash" : "1346f4d9e28529070ddd5d7ce630b824" } on : shard0002 Timestamp(86, 16) 
    { "hash" : "1346f4d9e28529070ddd5d7ce630b824" } -->> { "hash" : "1692c5e0adbae6847c1595976cf308e8" } on : shard0002 Timestamp(86, 17) 
    { "hash" : "1692c5e0adbae6847c1595976cf308e8" } -->> { "hash" : "1817e8910d67a14a1ccb0ce68074f283" } on : shard0004 Timestamp(24, 0) 
    { "hash" : "1817e8910d67a14a1ccb0ce68074f283" } -->> { "hash" : "199d8813d2533204d363c0eb05508d5a" } on : shard0005 Timestamp(25, 0) 
    { "hash" : "199d8813d2533204d363c0eb05508d5a" } -->> { "hash" : "1b23becfb6b654b7a830311a709c1eb8" } on : shard0006 Timestamp(26, 0) 
    { "hash" : "1b23becfb6b654b7a830311a709c1eb8" } -->> { "hash" : "1caa0fe0fc3a76ce12de781137cbb2e0" } on : shard0007 Timestamp(27, 0) 
    { "hash" : "1caa0fe0fc3a76ce12de781137cbb2e0" } -->> { "hash" : "1e83e11811d7dd326f15f1ff16fb8d7f" } on : shard0007 Timestamp(43, 0) 
    { "hash" : "1e83e11811d7dd326f15f1ff16fb8d7f" } -->> { "hash" : "204473f57239f124b5e2fa6a0ce5b3de" } on : shard0004 Timestamp(45, 0) 
    { "hash" : "204473f57239f124b5e2fa6a0ce5b3de" } -->> { "hash" : "2122bff14ade54acabf809fcdd9fb3fb" } on : shard0005 Timestamp(59, 0) 
    { "hash" : "2122bff14ade54acabf809fcdd9fb3fb" } -->> { "hash" : "2201978401c65849099954200f0d98c6" } on : shard0007 Timestamp(61, 0) 
    { "hash" : "2201978401c65849099954200f0d98c6" } -->> { "hash" : "2365f97f0af5b10ef082ac2fa94213c7" } on : shard0004 Timestamp(62, 0) 
    { "hash" : "2365f97f0af5b10ef082ac2fa94213c7" } -->> { "hash" : "2423ecbcb32549275ea1bbead7f1a6d2" } on : shard0005 Timestamp(63, 0) 
    { "hash" : "2423ecbcb32549275ea1bbead7f1a6d2" } -->> { "hash" : "24e204818b0e5dfa8c62c1840b7b36c9" } on : shard0006 Timestamp(64, 0) 
    { "hash" : "24e204818b0e5dfa8c62c1840b7b36c9" } -->> { "hash" : "26a8fcef33cdb12ca0f9c8e964884e25" } on : shard0004 Timestamp(12, 0) 
    { "hash" : "26a8fcef33cdb12ca0f9c8e964884e25" } -->> { "hash" : "286fdb86a0ad33fce45d48ba8aeaed76" } on : shard0005 Timestamp(13, 0) 
    { "hash" : "286fdb86a0ad33fce45d48ba8aeaed76" } -->> { "hash" : "2a36d5c6818e42393dff73fd9d36825e" } on : shard0006 Timestamp(14, 0) 
    { "hash" : "2a36d5c6818e42393dff73fd9d36825e" } -->> { "hash" : "2bfd3f123776c882402fb366caae69ef" } on : shard0007 Timestamp(15, 0) 
    { "hash" : "2bfd3f123776c882402fb366caae69ef" } -->> { "hash" : "2dc863db22aa527a1ab5c38fb4c5b79f" } on : shard0004 Timestamp(16, 0) 
    { "hash" : "2dc863db22aa527a1ab5c38fb4c5b79f" } -->> { "hash" : "2f952392172750d70ad3b33e52409dd7" } on : shard0005 Timestamp(17, 0) 
    { "hash" : "2f952392172750d70ad3b33e52409dd7" } -->> { "hash" : "316103318efd305dba54b3de6aeaa4e8" } on : shard0006 Timestamp(18, 0) 
    { "hash" : "316103318efd305dba54b3de6aeaa4e8" } -->> { "hash" : "332f1bacc24a66fd63d9a709a473d883" } on : shard0007 Timestamp(19, 0) 
    { "hash" : "332f1bacc24a66fd63d9a709a473d883" } -->> { "hash" : "3494d9e02071844bcc3d452f9279589f" } on : shard0005 Timestamp(29, 0) 
    { "hash" : "3494d9e02071844bcc3d452f9279589f" } -->> { "hash" : "35fb652c9a3222f995fe94f43cc771e0" } on : shard0006 Timestamp(30, 0) 
    { "hash" : "35fb652c9a3222f995fe94f43cc771e0" } -->> { "hash" : "3762fd13a6ce6ad6660b760762db63de" } on : shard0007 Timestamp(31, 0) 
    { "hash" : "3762fd13a6ce6ad6660b760762db63de" } -->> { "hash" : "38ca4719fbd5c7043d406a0c3212f50d" } on : shard0004 Timestamp(32, 0) 
    { "hash" : "38ca4719fbd5c7043d406a0c3212f50d" } -->> { "hash" : "39ba62b8fc12ec9a82e814ae22abc639" } on : shard0007 Timestamp(57, 0) 
    { "hash" : "39ba62b8fc12ec9a82e814ae22abc639" } -->> { "hash" : "3aab998023c585aee431faf50ccad1be" } on : shard0004 Timestamp(58, 0) 
    { "hash" : "3aab998023c585aee431faf50ccad1be" } -->> { "hash" : "3c3b142b4600a277253d62a9e59495fb" } on : shard0006 Timestamp(60, 0) 
    { "hash" : "3c3b142b4600a277253d62a9e59495fb" } -->> { "hash" : "3d91ce54fad93712c7cac10143618671" } on : shard0005 Timestamp(67, 0) 
    { "hash" : "3d91ce54fad93712c7cac10143618671" } -->> { "hash" : "3e9e53ff48d9a9da3c783937f52ac178" } on : shard0004 Timestamp(70, 0) 
    { "hash" : "3e9e53ff48d9a9da3c783937f52ac178" } -->> { "hash" : "3fab92c377ea67884e77eec02751b822" } on : shard0005 Timestamp(71, 0) 
    { "hash" : "3fab92c377ea67884e77eec02751b822" } -->> { "hash" : "406b30881e6627f7cd5b4473e7b295b5" } on : shard0006 Timestamp(72, 0) 
    { "hash" : "406b30881e6627f7cd5b4473e7b295b5" } -->> { "hash" : "412bbe8c021e45cd03389921abef23d8" } on : shard0007 Timestamp(77, 0) 
    { "hash" : "412bbe8c021e45cd03389921abef23d8" } -->> { "hash" : "41d96299f6865b2dc1791a5e8d3870fa" } on : shard0004 Timestamp(82, 0) 
    { "hash" : "41d96299f6865b2dc1791a5e8d3870fa" } -->> { "hash" : "4287d3ac80457ced47c2204a61c89c4e" } on : shard0005 Timestamp(83, 0) 
    { "hash" : "4287d3ac80457ced47c2204a61c89c4e" } -->> { "hash" : "43c9eac00f88103926311705c65a592f" } on : shard0007 Timestamp(85, 0) 
    { "hash" : "43c9eac00f88103926311705c65a592f" } -->> { "hash" : "448cc55c43dcc80a5b3ee365408294de" } on : shard0004 Timestamp(90, 0) 
    { "hash" : "448cc55c43dcc80a5b3ee365408294de" } -->> { "hash" : "454fd98710d7f6b8a6ca42c116a720be" } on : shard0005 Timestamp(91, 0) 
    { "hash" : "454fd98710d7f6b8a6ca42c116a720be" } -->> { "hash" : "4613a1f5e7623aa2b8ce5220ef207428" } on : shard0006 Timestamp(92, 0) 
    { "hash" : "4613a1f5e7623aa2b8ce5220ef207428" } -->> { "hash" : "46d6b1749a62824ec317fda78d436ec4" } on : shard0007 Timestamp(93, 0) 
    { "hash" : "46d6b1749a62824ec317fda78d436ec4" } -->> { "hash" : "479ad065a429d297cae7234419eb1d9d" } on : shard0004 Timestamp(94, 0) 
    { "hash" : "479ad065a429d297cae7234419eb1d9d" } -->> { "hash" : "485e5b8cf9f8f5a8245f7b893ac60240" } on : shard0005 Timestamp(95, 0) 
    { "hash" : "485e5b8cf9f8f5a8245f7b893ac60240" } -->> { "hash" : "49b2ee2792b86873e7891f43453478b6" } on : shard0003 Timestamp(95, 1) 
    { "hash" : "49b2ee2792b86873e7891f43453478b6" } -->> { "hash" : "4aee88c9976990eb2f2e52a6ea6b4d0b" } on : shard0003 Timestamp(81, 14) 
    { "hash" : "4aee88c9976990eb2f2e52a6ea6b4d0b" } -->> { "hash" : "4c042e5b974325dd87e8c2093cb7809f" } on : shard0003 Timestamp(91, 4) 
    { "hash" : "4c042e5b974325dd87e8c2093cb7809f" } -->> { "hash" : "4f01c23152e8c23eb685f0f1ccd3574a" } on : shard0003 Timestamp(91, 5) 
    { "hash" : "4f01c23152e8c23eb685f0f1ccd3574a" } -->> { "hash" : "507cddde3ffb51492a3a32457b3c8680" } on : shard0003 Timestamp(60, 4) 
    { "hash" : "507cddde3ffb51492a3a32457b3c8680" } -->> { "hash" : "51d74c15a9832c5ab881354835e7c3f0" } on : shard0003 Timestamp(66, 10) 
    { "hash" : "51d74c15a9832c5ab881354835e7c3f0" } -->> { "hash" : "5327cd130720e69b56164d5bc7cf47e2" } on : shard0003 Timestamp(76, 4) 
    { "hash" : "5327cd130720e69b56164d5bc7cf47e2" } -->> { "hash" : "54426cbf461bb1a3a43f44012f8afaf8" } on : shard0003 Timestamp(89, 4) 
    { "hash" : "54426cbf461bb1a3a43f44012f8afaf8" } -->> { "hash" : "558078d76f9ba43477bacbed2640414b" } on : shard0003 Timestamp(89, 5) 
    { "hash" : "558078d76f9ba43477bacbed2640414b" } -->> { "hash" : "56fac1c343349227bc39c5f72be82dd4" } on : shard0003 Timestamp(56, 14) 
    { "hash" : "56fac1c343349227bc39c5f72be82dd4" } -->> { "hash" : "5854da68fae12e4afdb32ec5172698cc" } on : shard0003 Timestamp(66, 12) 
    { "hash" : "5854da68fae12e4afdb32ec5172698cc" } -->> { "hash" : "59a4d26a918d536e8da3eb3c48b8b66e" } on : shard0003 Timestamp(71, 8) 
    { "hash" : "59a4d26a918d536e8da3eb3c48b8b66e" } -->> { "hash" : "5c134f1e081b25e0be638c97ac45f9fe" } on : shard0003 Timestamp(71, 9) 
    { "hash" : "5c134f1e081b25e0be638c97ac45f9fe" } -->> { "hash" : "5dd232bd88633d2a6d8b81a26d6a4bf6" } on : shard0003 Timestamp(39, 18) 
    { "hash" : "5dd232bd88633d2a6d8b81a26d6a4bf6" } -->> { "hash" : "5f69838082adb58883e5e4b6ac36ebe7" } on : shard0003 Timestamp(49, 16) 
    { "hash" : "5f69838082adb58883e5e4b6ac36ebe7" } -->> { "hash" : "60b31719bcb9d2e9da906c8ef24d6b58" } on : shard0003 Timestamp(81, 4) 
    { "hash" : "60b31719bcb9d2e9da906c8ef24d6b58" } -->> { "hash" : "61d843a4a9fb8c3ded6806732d8d7c32" } on : shard0003 Timestamp(87, 6) 
    { "hash" : "61d843a4a9fb8c3ded6806732d8d7c32" } -->> { "hash" : "6480d1d4442a1d46d750f68744c53d94" } on : shard0003 Timestamp(87, 7) 
    { "hash" : "6480d1d4442a1d46d750f68744c53d94" } -->> { "hash" : "663e424de9bd7f712ea89caf50d73cf5" } on : shard0003 Timestamp(39, 16) 
    { "hash" : "663e424de9bd7f712ea89caf50d73cf5" } -->> { "hash" : "67edb97c800788a891fb500deb400256" } on : shard0003 Timestamp(49, 6) 
    { "hash" : "67edb97c800788a891fb500deb400256" } -->> { "hash" : "697083691bee96e22eb50bdbefb8917b" } on : shard0003 Timestamp(56, 6) 
    { "hash" : "697083691bee96e22eb50bdbefb8917b" } -->> { "hash" : "6ae3c71cdff25b79d4102c2863d422fb" } on : shard0003 Timestamp(60, 12) 
    { "hash" : "6ae3c71cdff25b79d4102c2863d422fb" } -->> { "hash" : "6c33fe587906a9f7bf6bcab78c6c1608" } on : shard0003 Timestamp(76, 14) 
    { "hash" : "6c33fe587906a9f7bf6bcab78c6c1608" } -->> { "hash" : "6ed3040f678900d16c948ba19fe786bc" } on : shard0003 Timestamp(76, 15) 
    { "hash" : "6ed3040f678900d16c948ba19fe786bc" } -->> { "hash" : "702c035c360f5278d683f77606c69ebb" } on : shard0002 Timestamp(66, 8) 
    { "hash" : "702c035c360f5278d683f77606c69ebb" } -->> { "hash" : "71760e9813a6229d9116801328db471d" } on : shard0002 Timestamp(78, 6) 
    { "hash" : "71760e9813a6229d9116801328db471d" } -->> { "hash" : "74973d49c7393320989bd87d212e74e0" } on : shard0002 Timestamp(78, 7) 
    { "hash" : "74973d49c7393320989bd87d212e74e0" } -->> { "hash" : "761336135e0d2046bb5924e32c989d0f" } on : shard0002 Timestamp(56, 12) 
    { "hash" : "761336135e0d2046bb5924e32c989d0f" } -->> { "hash" : "7789da25534f6a446163857b6ca80585" } on : shard0002 Timestamp(60, 6) 
    { "hash" : "7789da25534f6a446163857b6ca80585" } -->> { "hash" : "78dba031c7d4f5130a7138a990d03777" } on : shard0002 Timestamp(71, 6) 
    { "hash" : "78dba031c7d4f5130a7138a990d03777" } -->> { "hash" : "7b9d5cd8befd19bb11b26a2063e99a79" } on : shard0002 Timestamp(71, 7) 
    { "hash" : "7b9d5cd8befd19bb11b26a2063e99a79" } -->> { "hash" : "7d22b7f188a06e82a2d539257e134141" } on : shard0002 Timestamp(56, 4) 
    { "hash" : "7d22b7f188a06e82a2d539257e134141" } -->> { "hash" : "7e8afb407f89298187a18109d0c0f9e6" } on : shard0002 Timestamp(60, 18) 
    { "hash" : "7e8afb407f89298187a18109d0c0f9e6" } -->> { "hash" : "7fef03cc84df8c33ec72904140b9a5fe" } on : shard0002 Timestamp(60, 24) 
    { "hash" : "7fef03cc84df8c33ec72904140b9a5fe" } -->> { "hash" : "81380bbdd0d4d07c5dd600250f0444af" } on : shard0002 Timestamp(81, 8) 
    { "hash" : "81380bbdd0d4d07c5dd600250f0444af" } -->> { "hash" : "82e680a43d730066c6d6d00f1be4e32a" } on : shard0002 Timestamp(81, 9) 
    { "hash" : "82e680a43d730066c6d6d00f1be4e32a" } -->> { "hash" : "846f27eef8b26bc874a030920d6f2dc8" } on : shard0002 Timestamp(53, 8) 
    { "hash" : "846f27eef8b26bc874a030920d6f2dc8" } -->> { "hash" : "85e2740d4d83be8292c24412db7a00a1" } on : shard0002 Timestamp(60, 10) 
    { "hash" : "85e2740d4d83be8292c24412db7a00a1" } -->> { "hash" : "873ed6e94dbe4d4b798cf819a7be9f87" } on : shard0002 Timestamp(66, 6) 
    { "hash" : "873ed6e94dbe4d4b798cf819a7be9f87" } -->> { "hash" : "886dab713c8c5fe42494dc487232b405" } on : shard0002 Timestamp(86, 14) 
    { "hash" : "886dab713c8c5fe42494dc487232b405" } -->> { "hash" : "8b453172ecbdb48e5877e6cfc7b79ee3" } on : shard0002 Timestamp(86, 15) 
    { "hash" : "8b453172ecbdb48e5877e6cfc7b79ee3" } -->> { "hash" : "8c148b1f1f6976ac486993ef2701e934" } on : shard0004 Timestamp(78, 0) 
    { "hash" : "8c148b1f1f6976ac486993ef2701e934" } -->> { "hash" : "8ce30d15961ce62b15e60eaf814ce45e" } on : shard0007 Timestamp(81, 0) 
    { "hash" : "8ce30d15961ce62b15e60eaf814ce45e" } -->> { "hash" : "8d9918897a24d6a64456b784f490b048" } on : shard0006 Timestamp(88, 0) 
    { "hash" : "8d9918897a24d6a64456b784f490b048" } -->> { "hash" : "8e4fabc8ca097b36debc0896b8b9a974" } on : shard0007 Timestamp(89, 0) 
    { "hash" : "8e4fabc8ca097b36debc0896b8b9a974" } -->> { "hash" : "8fb407f11e1212c4240ec06a979615b0" } on : shard0001 Timestamp(89, 1) 
    { "hash" : "8fb407f11e1212c4240ec06a979615b0" } -->> { "hash" : "90fdd7ab184255c02b99edda101796ae" } on : shard0001 Timestamp(78, 8) 
    { "hash" : "90fdd7ab184255c02b99edda101796ae" } -->> { "hash" : "94337e2ed8741d02028c33f5a238f2cd" } on : shard0001 Timestamp(78, 9) 
    { "hash" : "94337e2ed8741d02028c33f5a238f2cd" } -->> { "hash" : "95f40c00417a5a8ee692d459570a8551" } on : shard0001 Timestamp(39, 8) 
    { "hash" : "95f40c00417a5a8ee692d459570a8551" } -->> { "hash" : "97a4a2771fbf4e2633dae4d3009cb8b1" } on : shard0001 Timestamp(49, 4) 
    { "hash" : "97a4a2771fbf4e2633dae4d3009cb8b1" } -->> { "hash" : "99407767d9a265c1b19e506500b44aa5" } on : shard0001 Timestamp(49, 10) 
    { "hash" : "99407767d9a265c1b19e506500b44aa5" } -->> { "hash" : "9acc0d7e5308c0cb60d959db94d33318" } on : shard0001 Timestamp(53, 4) 
    { "hash" : "9acc0d7e5308c0cb60d959db94d33318" } -->> { "hash" : "9c419a178e32a05c2650cd31efcc858d" } on : shard0001 Timestamp(60, 8) 
    { "hash" : "9c419a178e32a05c2650cd31efcc858d" } -->> { "hash" : "9d8f77175b877cfc8febdf733e0a3f7a" } on : shard0001 Timestamp(76, 16) 
    { "hash" : "9d8f77175b877cfc8febdf733e0a3f7a" } -->> { "hash" : "9fbacbf5c378be80449aefcc198bfc68" } on : shard0001 Timestamp(76, 17) 
    { "hash" : "9fbacbf5c378be80449aefcc198bfc68" } -->> { "hash" : "a173b41b16b63a0102175a9e86052afd" } on : shard0001 Timestamp(45, 10) 
    { "hash" : "a173b41b16b63a0102175a9e86052afd" } -->> { "hash" : "a30085714610e8796ba21edc42665bf1" } on : shard0001 Timestamp(49, 24) 
    { "hash" : "a30085714610e8796ba21edc42665bf1" } -->> { "hash" : "a431f8333c13d93aadc195bb5b77ba7d" } on : shard0001 Timestamp(86, 12) 
    { "hash" : "a431f8333c13d93aadc195bb5b77ba7d" } -->> { "hash" : "a54f025a25dfd94a9d2b645c1d4f105a" } on : shard0001 Timestamp(87, 8) 
    { "hash" : "a54f025a25dfd94a9d2b645c1d4f105a" } -->> { "hash" : "a8c25e1ed3f156f7bf1b6ac03157b7c2" } on : shard0001 Timestamp(87, 9) 
    { "hash" : "a8c25e1ed3f156f7bf1b6ac03157b7c2" } -->> { "hash" : "aa28021b4afb48bd9624017ac9daf801" } on : shard0001 Timestamp(60, 22) 
    { "hash" : "aa28021b4afb48bd9624017ac9daf801" } -->> { "hash" : "ab7803bd7d42268f4595e461213b6359" } on : shard0001 Timestamp(76, 10) 
    { "hash" : "ab7803bd7d42268f4595e461213b6359" } -->> { "hash" : "acab1ba0757f0fa9a92c37eddd4db966" } on : shard0001 Timestamp(86, 10) 
    { "hash" : "acab1ba0757f0fa9a92c37eddd4db966" } -->> { "hash" : "aec8dd8cef8c5228c096615a471843a2" } on : shard0001 Timestamp(86, 11) 
    { "hash" : "aec8dd8cef8c5228c096615a471843a2" } -->> { "hash" : "b02fd4a1e43f5f991386583e5b448917" } on : shard0001 Timestamp(60, 20) 
    { "hash" : "b02fd4a1e43f5f991386583e5b448917" } -->> { "hash" : "b17f660d7f3a5f814e74054b3d79786c" } on : shard0001 Timestamp(76, 12) 
    { "hash" : "b17f660d7f3a5f814e74054b3d79786c" } -->> { "hash" : "b2c9640546e152d22e73ffa8522a751d" } on : shard0001 Timestamp(81, 6) 
    { "hash" : "b2c9640546e152d22e73ffa8522a751d" } -->> { "hash" : "b509b2eee0d8dec3798aa861ddbc624e" } on : shard0001 Timestamp(81, 7) 
    { "hash" : "b509b2eee0d8dec3798aa861ddbc624e" } -->> { "hash" : "b6ab24b872b93da5c1ddf2ec81b7aad4" } on : shard0004 Timestamp(20, 0) 
    { "hash" : "b6ab24b872b93da5c1ddf2ec81b7aad4" } -->> { "hash" : "b84c2a20458a7e4d23f63cacc43059db" } on : shard0005 Timestamp(21, 0) 
    { "hash" : "b84c2a20458a7e4d23f63cacc43059db" } -->> { "hash" : "b9ed7189c285195f4b2d97ebf85544a8" } on : shard0006 Timestamp(22, 0) 
    { "hash" : "b9ed7189c285195f4b2d97ebf85544a8" } -->> { "hash" : "bb8eea70aa9f24ca27c2c750d3cfecba" } on : shard0007 Timestamp(23, 0) 
    { "hash" : "bb8eea70aa9f24ca27c2c750d3cfecba" } -->> { "hash" : "bd37277ad4c7195a731e87d5156d399f" } on : shard0005 Timestamp(33, 0) 
    { "hash" : "bd37277ad4c7195a731e87d5156d399f" } -->> { "hash" : "bedfe4b2b12104ea2763b024e5ea0f91" } on : shard0006 Timestamp(34, 0) 
    { "hash" : "bedfe4b2b12104ea2763b024e5ea0f91" } -->> { "hash" : "c087e0f9bfb67d10108f2c71c294a910" } on : shard0007 Timestamp(35, 0) 
    { "hash" : "c087e0f9bfb67d10108f2c71c294a910" } -->> { "hash" : "c22f1c97f1664e067139fc2102cdb073" } on : shard0004 Timestamp(36, 0) 
    { "hash" : "c22f1c97f1664e067139fc2102cdb073" } -->> { "hash" : "c406a5973c2cac6b8cad5ad8698ac5cd" } on : shard0005 Timestamp(37, 0) 
    { "hash" : "c406a5973c2cac6b8cad5ad8698ac5cd" } -->> { "hash" : "c53057a7469ddb3f51a062db61c32eef" } on : shard0006 Timestamp(38, 0) 
    { "hash" : "c53057a7469ddb3f51a062db61c32eef" } -->> { "hash" : "c65a275c435186bdc0054a6439b2f7f3" } on : shard0007 Timestamp(39, 0) 
    { "hash" : "c65a275c435186bdc0054a6439b2f7f3" } -->> { "hash" : "c828020eee54d15dc00dba8b1561a582" } on : shard0004 Timestamp(40, 0) 
    { "hash" : "c828020eee54d15dc00dba8b1561a582" } -->> { "hash" : "c95491422e66ffc61951e7ef57d29a13" } on : shard0005 Timestamp(41, 0) 
    { "hash" : "c95491422e66ffc61951e7ef57d29a13" } -->> { "hash" : "ca81b2a02dc7c0d4f721179e2f48a757" } on : shard0006 Timestamp(42, 0) 
    { "hash" : "ca81b2a02dc7c0d4f721179e2f48a757" } -->> { "hash" : "cc41dc3b261b657f143cdf77153efcab" } on : shard0002 Timestamp(44, 0) 
    { "hash" : "cc41dc3b261b657f143cdf77153efcab" } -->> { "hash" : "cd5615582591ffd36f27ccc450c524ac" } on : shard0005 Timestamp(46, 0) 
    { "hash" : "cd5615582591ffd36f27ccc450c524ac" } -->> { "hash" : "ce69b42112fe21dcec992b0d13b50290" } on : shard0006 Timestamp(47, 0) 
    { "hash" : "ce69b42112fe21dcec992b0d13b50290" } -->> { "hash" : "cf7da3b87db92247aac8088d2a9dac13" } on : shard0007 Timestamp(48, 0) 
    { "hash" : "cf7da3b87db92247aac8088d2a9dac13" } -->> { "hash" : "d0925310a75c383588e09930430babb8" } on : shard0002 Timestamp(49, 0) 
    { "hash" : "d0925310a75c383588e09930430babb8" } -->> { "hash" : "d1a5fb98c9dca1ad1001890eb4b6cd10" } on : shard0004 Timestamp(50, 0) 
    { "hash" : "d1a5fb98c9dca1ad1001890eb4b6cd10" } -->> { "hash" : "d2ba22c4727afcc1536a2771375b8b9b" } on : shard0005 Timestamp(51, 0) 
    { "hash" : "d2ba22c4727afcc1536a2771375b8b9b" } -->> { "hash" : "d3cdb27b6bedf7d0fef98f20f8722c90" } on : shard0006 Timestamp(52, 0) 
    { "hash" : "d3cdb27b6bedf7d0fef98f20f8722c90" } -->> { "hash" : "d4e0eae78a93c8f8b5c8715b05e0906e" } on : shard0007 Timestamp(53, 0) 
    { "hash" : "d4e0eae78a93c8f8b5c8715b05e0906e" } -->> { "hash" : "d5bda846189ab8dbb2dfa167183d70e8" } on : shard0004 Timestamp(54, 0) 
    { "hash" : "d5bda846189ab8dbb2dfa167183d70e8" } -->> { "hash" : "d69ab5e2e3b44cdf045e2141dca9dc61" } on : shard0005 Timestamp(55, 0) 
    { "hash" : "d69ab5e2e3b44cdf045e2141dca9dc61" } -->> { "hash" : "d827e9558705964d23015e825a07118b" } on : shard0006 Timestamp(56, 0) 
    { "hash" : "d827e9558705964d23015e825a07118b" } -->> { "hash" : "d8cf0635028edb5243ddb7f0a076cfa8" } on : shard0000 Timestamp(95, 2) 
    { "hash" : "d8cf0635028edb5243ddb7f0a076cfa8" } -->> { "hash" : "d975fe6138a5106b43b1ed710279e7f1" } on : shard0000 Timestamp(95, 3) 
    { "hash" : "d975fe6138a5106b43b1ed710279e7f1" } -->> { "hash" : "db0f11ef744dd20e6e46ade8f96ff552" } on : shard0000 Timestamp(76, 9) 
    { "hash" : "db0f11ef744dd20e6e46ade8f96ff552" } -->> { "hash" : "dc5ec4b91fb2f881f8c335c2323dd6e3" } on : shard0000 Timestamp(76, 6) 
    { "hash" : "dc5ec4b91fb2f881f8c335c2323dd6e3" } -->> { "hash" : "ddf94593fb52923b45fceb9b52da7950" } on : shard0000 Timestamp(76, 7) 
    { "hash" : "ddf94593fb52923b45fceb9b52da7950" } -->> { "hash" : "dfb94d7e507c1a138bb8096271137dc1" } on : shard0000 Timestamp(39, 10) 
    { "hash" : "dfb94d7e507c1a138bb8096271137dc1" } -->> { "hash" : "e17539f28ffc06acbf4292f94a410e0b" } on : shard0000 Timestamp(45, 4) 
    { "hash" : "e17539f28ffc06acbf4292f94a410e0b" } -->> { "hash" : "e30d8cf587d9323c664620a951b5d918" } on : shard0000 Timestamp(49, 12) 
    { "hash" : "e30d8cf587d9323c664620a951b5d918" } -->> { "hash" : "e463550ca8f2d6d490930ac207561373" } on : shard0000 Timestamp(69, 4) 
    { "hash" : "e463550ca8f2d6d490930ac207561373" } -->> { "hash" : "e59d3288d6dc5c1fc4a6d138ba821429" } on : shard0000 Timestamp(86, 4) 
    { "hash" : "e59d3288d6dc5c1fc4a6d138ba821429" } -->> { "hash" : "e6c45710d115db22b183bd6498165206" } on : shard0000 Timestamp(87, 4) 
    { "hash" : "e6c45710d115db22b183bd6498165206" } -->> { "hash" : "e963f2db893ecac1092f180831333d55" } on : shard0000 Timestamp(87, 5) 
    { "hash" : "e963f2db893ecac1092f180831333d55" } -->> { "hash" : "eb43b54221873ba4ff6fab011618f39e" } on : shard0000 Timestamp(32, 8) 
    { "hash" : "eb43b54221873ba4ff6fab011618f39e" } -->> { "hash" : "ed0c264fe9019965ecd7ff5b41c9d23b" } on : shard0000 Timestamp(39, 4) 
    { "hash" : "ed0c264fe9019965ecd7ff5b41c9d23b" } -->> { "hash" : "eec5cc8e19a75d4af5ede17a44edb173" } on : shard0000 Timestamp(45, 12) 
    { "hash" : "eec5cc8e19a75d4af5ede17a44edb173" } -->> { "hash" : "f0503b2876715bdadddb9ff1da3c85d5" } on : shard0000 Timestamp(53, 6) 
    { "hash" : "f0503b2876715bdadddb9ff1da3c85d5" } -->> { "hash" : "f1d2ee4b2fd272eced421f3add4714f5" } on : shard0000 Timestamp(56, 8) 
    { "hash" : "f1d2ee4b2fd272eced421f3add4714f5" } -->> { "hash" : "f319f2a83d66adc96f550de8f5198968" } on : shard0000 Timestamp(81, 10) 
    { "hash" : "f319f2a83d66adc96f550de8f5198968" } -->> { "hash" : "f4837ce70d316e8927183e59462a8009" } on : shard0000 Timestamp(81, 11) 
    { "hash" : "f4837ce70d316e8927183e59462a8009" } -->> { "hash" : "f662ad89d4166692388f34eb64e8f98b" } on : shard0000 Timestamp(32, 6) 
    { "hash" : "f662ad89d4166692388f34eb64e8f98b" } -->> { "hash" : "f81d4be726d786777e9033292bc54cf9" } on : shard0000 Timestamp(45, 6) 
    { "hash" : "f81d4be726d786777e9033292bc54cf9" } -->> { "hash" : "f9ab2ccbd3796823054a9ac6315b9ef9" } on : shard0000 Timestamp(49, 20) 
    { "hash" : "f9ab2ccbd3796823054a9ac6315b9ef9" } -->> { "hash" : "faf631b3f9f5bbf5ed004761784aab59" } on : shard0000 Timestamp(78, 4) 
    { "hash" : "faf631b3f9f5bbf5ed004761784aab59" } -->> { "hash" : "fc2cd371bf17ba7bebf7f50cdcf8410f" } on : shard0000 Timestamp(86, 8) 
    { "hash" : "fc2cd371bf17ba7bebf7f50cdcf8410f" } -->> { "hash" : "fffd8df39bff09604b965fd80fcfcbd1" } on : shard0000 Timestamp(86, 9) 
    { "hash" : "fffd8df39bff09604b965fd80fcfcbd1" } -->> { "hash" : { "$maxKey" : 1 } } on : shard0001 Timestamp(4, 1)

更新:为lastMigration添加了结果

{
        "clientAddr" : ":27017",
        "time" : ISODate("2014-07-28T17:09:37.603Z"),
        "what" : "moveChunk.to",
        "details" : {
                "min" : {
                        "hash" : "479ad065a429d297cae7234419eb1d9d"
                },
                "max" : {
                        "hash" : "485e5b8cf9f8f5a8245f7b893ac60240"
                },
                "step1 of 5" : 3,
                "step2 of 5" : 0,
                "step3 of 5" : 197310,
                "step4 of 5" : 2,
                "step5 of 5" : 591
        }
}

1 个答案:

答案 0 :(得分:3)

所以这里 -

您看到的行为似乎正常或接近正常的MongoDB分片活动。我将在下面详细解释原因。

如果默认块大小为64MB和179块,则总数据大小不超过11​​GB(最大64MB块时间179)。它很可能在那之下。

然而,您有8个分片 - 这意味着您已经在大量分片/块中分发了(相对)少量数据。这导致数据分布出现一些明显的不均匀性,直到您拥有更多块或减少分片数量才能解决,这样每​​个分片就会有更多的块。

首先关闭MongoDB平衡器,与普遍看法相反,并不能保持一切准确平衡。它根据某些阈值启动,然后在达到其他阈值时关闭。否则会不断捶打。

可在此处找到阈值:http://docs.mongodb.org/manual/core/sharding-balancing/

  • 少于20个块:平衡器中有2个块差异
  • 20-79块:平衡器中的4块差异
  • 80及以上:平衡器中有8个区块差异

在你的情况下,超过80个块,你将不会迁移,直到最大和最小分片(块数)之间的差异至少为8.你的最大差异现在是5,在shard0000上的25个块之间和shard0006和shard00007上的20个块。这解释了一些重要的差异。

请注意,默认的平衡器行为不是将差异驱动为0 - 因此当您添加新分片时,新分片将以较少的块开始,因为当最大分片和最小分片之间的差异为2时迁移停止

当你每个碎片有大量的块时,这种差异并不明显 - 但你没有。所以这将继续引人注目,直到每个碎片的块浓度高得多。

添加较小的新分片后,正在进行的数据分发取决于数据在分片键中的均匀分布。基于日期的键或其他稳定增加的键创建热点 - 完全随机键接近完美均匀分布。

查看您的分片中当前的块分布并假设您的迁移平衡到每个分片的2个块(注意这是一个假设 - 它可能在此之前已经停止并出现错误)看起来您可能没有完全随机的哈希密钥,因为分布看起来有点偏颇。

请注意,这是"可能" - 可能是由于错误而停止的不完整平衡器运行的工件。

无论如何,你不可能看到完美的"平衡。在足够的新数据进入之后,您应该看到更接近的平衡,使得每个分片的块总数>>>那么门槛。现在,每个碎片有20-25块,开始阈值为8差异,停止阈值为2差异,你将继续看到数据平衡的显着差异,旧的,更大的碎片总是保持更大。

使用当前分布,你需要一个碎片才能达到28个块,而另一个碎片在平衡器开始之前需要20个块 - 相差40%。假设所有块都是相同的大小 - 将新数据分配给块的任何偏差都会使该数字偏斜。

如果4个分片上的块数相同而不是8个,则平衡器启动时的差异仅为20%。因此,有大量的分片和少量的块会使这个问题更加糟糕。

要进一步研究的一件事是每个块有多大 - 不容易通过现有的MongoDB工具直接确定,但有一些代码可能会有所帮助:

https://github.com/comerford/mongodb-scripts/blob/master/AllChunkInfo.js

请注意,我会先在测试中试一试。目标是了解你的块是否合理均匀,如果没有,为什么不。