当我添加一个新的碎片时,mongodb重新平衡很慢

时间:2013-08-27 06:32:26

标签: mongodb sharding

我有一个简单的分片MongoDB设置:4个分片,每个分片是一个副本集。昨天,我在群集中添加了一个新的分片(副本集),使其成为5个分片,但它重新平衡得太慢,移动一个块( 64m)用了一天。

mongos> db.currentOp()
{
        "inprog" : [
                {
                        "opid" : "rs0:1065042",
                        "active" : true,
                        "secs_running" : 2,
                        "op" : "getmore",
                        "ns" : "local.oplog.rs",
                        "query" : {
                                "ts" : {
                                        "$gte" : {
                                                "t" : 1377488004,
                                                "i" : 498
                                        }
                                }
                        },
                        "client_s" : "192.168.0.64:55163",
                        "desc" : "conn9",
                        "threadId" : "0x7fa516c6c700",
                        "connectionId" : 9,
                        "waitingForLock" : false,
                        "numYields" : 0,
                        "lockStats" : {
                                "timeLockedMicros" : {
                                        "r" : NumberLong(80),
                                        "w" : NumberLong(0)
                                },
                                "timeAcquiringMicros" : {
                                        "r" : NumberLong(14),
                                        "w" : NumberLong(0)
                                }
                        }
                },
                {
                        "opid" : "rs0:76801",
                        "active" : true,
                        "secs_running" : 83287,
                        "op" : "query",
                        "ns" : "weibo.status",
                        "query" : {
                                "moveChunk" : "weibo.status",
                                "from" : "rs0/192.168.0.57:10000,192.168.0.64:10000",
                                "to" : "rs4/192.168.0.62:10000",
                                "fromShard" : "rs0",
                                "toShard" : "rs4",
                                "min" : {
                                        "User._id" : ObjectId("000000000000001637703592")
                                },
                                "max" : {
                                        "User._id" : ObjectId("000000000000001637952115")
                                },
                                "maxChunkSizeBytes" : NumberLong(67108864),
                                "shardId" : "weibo.status-User._id_ObjectId('000000000000001637703592')",
                                "configdb" : "192.168.0.57:10010,192.168.0.58:10010,192.168.0.59:10010",
                                "secondaryThrottle" : true,
                                "waitForDelete" : false
                        },
                        "client_s" : "192.168.0.60:33047",
                        "desc" : "conn21",
                        "threadId" : "0x7fa516365700",
                        "connectionId" : 21,
                        "waitingForLock" : false,
                        "msg" : "step3 of 6",
                        "numYields" : 8,
                        "lockStats" : {
                                "timeLockedMicros" : {
                                        "r" : NumberLong(2704354),
                                        "w" : NumberLong(0)
                                },
                                "timeAcquiringMicros" : {
                                        "r" : NumberLong(1329771),
                                        "w" : NumberLong(0)
                                }
                        }
                },
                {
                        "opid" : "rs1:1023257",
                        "active" : true,
                        "secs_running" : 2,
                        "op" : "getmore",
                        "ns" : "local.oplog.rs",
                        "query" : {
                                "ts" : {
                                        "$gte" : {
                                                "t" : 1377487880,
                                                "i" : 9
                                        }
                                }
                        },
                        "client_s" : "192.168.0.65:36693",
                        "desc" : "conn24",
                        "threadId" : "0x7f6738450700",
                        "connectionId" : 24,
                        "waitingForLock" : false,
                        "numYields" : 0,
                        "lockStats" : {
                                "timeLockedMicros" : {
                                        "r" : NumberLong(35),
                                        "w" : NumberLong(0)
                                },
                                "timeAcquiringMicros" : {
                                        "r" : NumberLong(6),
                                        "w" : NumberLong(0)
                                }
                        }
                },
                {
                        "opid" : "rs2:488339",
                        "active" : true,
                        "secs_running" : 1,
                        "op" : "getmore",
                        "ns" : "local.oplog.rs",
                        "query" : {
                                "ts" : {
                                        "$gte" : {
                                                "t" : 1377487952,
                                                "i" : 1
                                        }
                                }
                        },
                        "client_s" : "192.168.0.66:48924",
                        "desc" : "conn30",
                        "threadId" : "0x7fc2e6ec6700",
                        "connectionId" : 30,
                        "waitingForLock" : false,
                        "numYields" : 0,
                        "lockStats" : {
                                "timeLockedMicros" : {
                                        "r" : NumberLong(22),
                                        "w" : NumberLong(0)
                                },
                                "timeAcquiringMicros" : {
                                        "r" : NumberLong(5),
                                        "w" : NumberLong(0)
                                }
                        }
                },
                {
                        "opid" : "rs3:427991",
                        "active" : true,
                        "secs_running" : 2,
                        "op" : "getmore",
                        "ns" : "local.oplog.rs",
                        "query" : {
                                "ts" : {
                                        "$gte" : {
                                                "t" : 1377498918,
                                                "i" : 1
                                        }
                                }
                        },
                        "client_s" : "192.168.0.67:50895",
                        "desc" : "conn32",
                        "threadId" : "0x7f184ab16700",
                        "connectionId" : 32,
                        "waitingForLock" : false,
                        "numYields" : 0,
                        "lockStats" : {
                                "timeLockedMicros" : {
                                        "r" : NumberLong(31),
                                        "w" : NumberLong(0)
                                },
                                "timeAcquiringMicros" : {
                                        "r" : NumberLong(5),
                                        "w" : NumberLong(0)
                                }
                        }
                }
        ]
}

分片状态:

mongos> sh.status()
--- Sharding Status ---
  sharding version: {
        "_id" : 1,
        "version" : 3,
        "minCompatibleVersion" : 3,
        "currentVersion" : 4,
        "clusterId" : ObjectId("51b1979ee2599912d7c2eb3e")
}
  shards:
        {  "_id" : "rs0",  "host" : "rs0/192.168.0.57:10000,192.168.0.64:10000" }
        {  "_id" : "rs1",  "host" : "rs1/192.168.0.58:10000,192.168.0.65:10000" }
        {  "_id" : "rs2",  "host" : "rs2/192.168.0.59:10000,192.168.0.66:10000" }
        {  "_id" : "rs3",  "host" : "rs3/192.168.0.60:10000,192.168.0.67:10000" }
        {  "_id" : "rs4",  "host" : "rs4/192.168.0.62:10000" }
  databases:
        {  "_id" : "admin",  "partitioned" : false,  "primary" : "config" }
        {  "_id" : "weibo",  "partitioned" : true,  "primary" : "rs0" }
                weibo.friend
                        shard key: { "_id" : 1 }
                        chunks:
                                rs0     1
                        { "_id" : { "$minKey" : 1 } } -->> { "_id" : { "$maxKey" : 1 } } on : rs0 { "t" : 1, "i" : 0 }
                weibo.status
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     8167
                                rs3     8042
                                rs2     8198
                                rs0     9984
                        too many chunks to print, use verbose if you want to force print
                weibo.status_2009_1
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs0     1
                        { "User._id" : { "$minKey" : 1 } } -->> { "User._id" : { "$maxKey" : 1 } } on : rs0 { "t" : 1, "i" : 0 }
                weibo.status_2009_2
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     1
                                rs0     1
                        { "User._id" : { "$minKey" : 1 } } -->> { "User._id" : ObjectId("000000000000001165660113") } on : rs1 { "t" : 2, "i" : 0 }
                        { "User._id" : ObjectId("000000000000001165660113") } -->> { "User._id" : { "$maxKey" : 1 } } on : rs0 { "t" : 2, "i" : 1 }
                weibo.status_2009_3
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     1
                                rs2     1
                                rs0     1
                        { "User._id" : { "$minKey" : 1 } } -->> { "User._id" : ObjectId("000000000000001630529257") } on : rs1 { "t" : 2, "i" : 0 }
                        { "User._id" : ObjectId("000000000000001630529257") } -->> { "User._id" : ObjectId("000000000000001650516303") } on : rs2 { "t" : 3, "i" : 0 }
                        { "User._id" : ObjectId("000000000000001650516303") } -->> { "User._id" : { "$maxKey" : 1 } } on : rs0 { "t" : 3, "i" : 1 }
                weibo.status_2009_4
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     1
                                rs2     1
                                rs3     1
                                rs0     1
                        { "User._id" : { "$minKey" : 1 } } -->> { "User._id" : ObjectId("000000000000001002443221") } on : rs1 { "t" : 2, "i" : 0 }
                        { "User._id" : ObjectId("000000000000001002443221") } -->> { "User._id" : ObjectId("000000000000001655036665") } on : rs2 { "t" : 3, "i" : 0 }
                        { "User._id" : ObjectId("000000000000001655036665") } -->> { "User._id" : ObjectId("000000000000001677004367") } on : rs3 { "t" : 4, "i" : 0 }
                        { "User._id" : ObjectId("000000000000001677004367") } -->> { "User._id" : { "$maxKey" : 1 } } on : rs0 { "t" : 4, "i" : 1 }
                weibo.status_2010_1
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     1
                                rs3     1
                                rs2     2
                                rs0     1
                        { "User._id" : { "$minKey" : 1 } } -->> { "User._id" : ObjectId("000000000000000251907773") } on : rs1 { "t" : 2, "i" : 0 }
                        { "User._id" : ObjectId("000000000000000251907773") } -->> { "User._id" : ObjectId("000000000000001581262961") } on : rs3 { "t" : 4, "i" : 0 }
                        { "User._id" : ObjectId("000000000000001581262961") } -->> { "User._id" : ObjectId("000000000000001670342047") } on : rs2 { "t" : 4, "i" : 1 }
                        { "User._id" : ObjectId("000000000000001670342047") } -->> { "User._id" : ObjectId("000000000000001717920874") } on : rs2 { "t" : 3, "i" : 5 }
                        { "User._id" : ObjectId("000000000000001717920874") } -->> { "User._id" : { "$maxKey" : 1 } } on : rs0 { "t" : 3, "i" : 1 }
                weibo.status_2010_2
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     1
                                rs2     2
                                rs3     3
                                rs0     1
                        { "User._id" : { "$minKey" : 1 } } -->> { "User._id" : ObjectId("000000000000000251907773") } on : rs1 { "t" : 2, "i" : 0 }
                        { "User._id" : ObjectId("000000000000000251907773") } -->> { "User._id" : ObjectId("000000000000001414460744") } on : rs2 { "t" : 4, "i" : 4 }
                        { "User._id" : ObjectId("000000000000001414460744") } -->> { "User._id" : ObjectId("000000000000001664671192") } on : rs2 { "t" : 4, "i" : 5 }
                        { "User._id" : ObjectId("000000000000001664671192") } -->> { "User._id" : ObjectId("000000000000001721752193") } on : rs3 { "t" : 4, "i" : 2 }
                        { "User._id" : ObjectId("000000000000001721752193") } -->> { "User._id" : ObjectId("000000000000001736802123") } on : rs3 { "t" : 4, "i" : 6 }
                        { "User._id" : ObjectId("000000000000001736802123") } -->> { "User._id" : ObjectId("000000000000001785220335") } on : rs3 { "t" : 4, "i" : 7 }
                        { "User._id" : ObjectId("000000000000001785220335") } -->> { "User._id" : { "$maxKey" : 1 } } on : rs0 { "t" : 4, "i" : 1 }
                weibo.status_2010_3
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     2
                                rs2     3
                                rs3     2
                                rs0     3
                        { "User._id" : { "$minKey" : 1 } } -->> { "User._id" : ObjectId("000000000000001342784851") } on : rs1 { "t" : 2, "i" : 0 }
                        { "User._id" : ObjectId("000000000000001342784851") } -->> { "User._id" : ObjectId("000000000000001591403661") } on : rs1 { "t" : 5, "i" : 0 }
                        { "User._id" : ObjectId("000000000000001591403661") } -->> { "User._id" : ObjectId("000000000000001679103562") } on : rs2 { "t" : 5, "i" : 1 }
                        { "User._id" : ObjectId("000000000000001679103562") } -->> { "User._id" : ObjectId("000000000000001738510785") } on : rs2 { "t" : 4, "i" : 8 }
                        { "User._id" : ObjectId("000000000000001738510785") } -->> { "User._id" : ObjectId("000000000000001767600673") } on : rs2 { "t" : 4, "i" : 9 }
                        { "User._id" : ObjectId("000000000000001767600673") } -->> { "User._id" : ObjectId("000000000000001777372031") } on : rs3 { "t" : 4, "i" : 10 }
                        { "User._id" : ObjectId("000000000000001777372031") } -->> { "User._id" : ObjectId("000000000000001790595097") } on : rs3 { "t" : 4, "i" : 11 }
                        { "User._id" : ObjectId("000000000000001790595097") } -->> { "User._id" : ObjectId("000000000000001802728227") } on : rs0 { "t" : 4, "i" : 2 }
                        { "User._id" : ObjectId("000000000000001802728227") } -->> { "User._id" : ObjectId("000000000000001841809925") } on : rs0 { "t" : 4, "i" : 3 }
                        { "User._id" : ObjectId("000000000000001841809925") } -->> { "User._id" : { "$maxKey" : 1 } } on : rs0 { "t" : 1, "i" : 4 }
                weibo.status_2010_4
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     2
                                rs2     2
                                rs3     1
                                rs0     6
                        { "User._id" : { "$minKey" : 1 } } -->> { "User._id" : ObjectId("000000000000001342784851") } on : rs1 { "t" : 2, "i" : 0 }
                        { "User._id" : ObjectId("000000000000001342784851") } -->> { "User._id" : ObjectId("000000000000001619454413") } on : rs2 { "t" : 4, "i" : 4 }
                        { "User._id" : ObjectId("000000000000001619454413") } -->> { "User._id" : ObjectId("000000000000001716045721") } on : rs2 { "t" : 4, "i" : 5 }
                        { "User._id" : ObjectId("000000000000001716045721") } -->> { "User._id" : ObjectId("000000000000001782379745") } on : rs3 { "t" : 4, "i" : 0 }
                        { "User._id" : ObjectId("000000000000001782379745") } -->> { "User._id" : ObjectId("000000000000001805244393") } on : rs1 { "t" : 5, "i" : 0 }
                        { "User._id" : ObjectId("000000000000001805244393") } -->> { "User._id" : ObjectId("000000000000001827399335") } on : rs0 { "t" : 5, "i" : 1 }
                        { "User._id" : ObjectId("000000000000001827399335") } -->> { "User._id" : ObjectId("000000000000001841677661") } on : rs0 { "t" : 3, "i" : 2 }
                        { "User._id" : ObjectId("000000000000001841677661") } -->> { "User._id" : ObjectId("000000000000001852657387") } on : rs0 { "t" : 3, "i" : 3 }
                        { "User._id" : ObjectId("000000000000001852657387") } -->> { "User._id" : ObjectId("000000000000001878545495") } on : rs0 { "t" : 1, "i" : 13 }
                        { "User._id" : ObjectId("000000000000001878545495") } -->> { "User._id" : ObjectId("000000000000001901429413") } on : rs0 { "t" : 1, "i" : 14 }
                        { "User._id" : ObjectId("000000000000001901429413") } -->> { "User._id" : { "$maxKey" : 1 } } on : rs0 { "t" : 1, "i" : 4 }
                weibo.status_2011_1
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     2
                                rs2     3
                                rs3     4
                                rs0     11
                        too many chunks to print, use verbose if you want to force print
                weibo.status_2011_2
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     2
                                rs2     1
                                rs3     1
                                rs0     16
                        too many chunks to print, use verbose if you want to force print
                weibo.status_2011_3
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     2
                                rs2     2
                                rs3     2
                                rs0     28
                        too many chunks to print, use verbose if you want to force print
                weibo.status_2011_4
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     2
                                rs2     2
                                rs3     2
                                rs0     39
                        too many chunks to print, use verbose if you want to force print
                weibo.status_2012_1
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     2
                                rs2     4
                                rs3     4
                                rs0     53
                        too many chunks to print, use verbose if you want to force print
                weibo.status_2012_2
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     2
                                rs2     2
                                rs3     3
                                rs0     81
                        too many chunks to print, use verbose if you want to force print
                weibo.status_2012_3
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     2
                                rs2     3
                                rs3     2
                                rs0     119
                        too many chunks to print, use verbose if you want to force print
                weibo.status_2012_4
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     2
                                rs2     4
                                rs3     3
                                rs0     359
                        too many chunks to print, use verbose if you want to force print
                weibo.status_2013_1
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     2
                                rs2     2
                                rs3     3
                                rs0     1111
                        too many chunks to print, use verbose if you want to force print
                weibo.status_2013_2
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     2
                                rs2     2
                                rs3     4
                                rs0     1323
                        too many chunks to print, use verbose if you want to force print
                weibo.status_2013_3
                        shard key: { "User._id" : 1 }
                        chunks:
                                rs1     2
                                rs2     14
                                rs3     28
                                rs0     1257
                        too many chunks to print, use verbose if you want to force print
                weibo.user
                        shard key: { "Province" : 1, "_id" : 1 }
                        chunks:
                                rs3     250
                                rs2     250
                                rs1     250
                                rs0     253
                        too many chunks to print, use verbose if you want to force print
        {  "_id" : "user_estate2",  "partitioned" : false,  "primary" : "rs2" }

0 个答案:

没有答案