需求:emperor中的data_edit_log.45f7d791-f9df-4710-82be-6708479a1126集合只落到了rs06分片,需要平均到各个分片中去
- use admin
- var origin_rs="rs06";
- var namespace = "emperor.data_edit_log.45f7d791-f9df-4710-82be-6708479a1126";
- var cursor = db.getSiblingDB("config").chunks.find({ns:namespace,shard:origin_rs});
- var count=-1;
- var shServer = [ "rs01", "rs02", "rs03", "rs04", "rs05", "rs07", "rs08",origin_rs];
- while (cursor.hasNext()) {
- count++
- var chunk = cursor.next();
- if(shServer[count]==origin_rs){
- print(count,shServer[count])
- count=0;
- continue;
- }
- var ret = db.runCommand({moveChunk :namespace, find : chunk.min, to : shServer[count]});
- printjson(ret);
- }
执行完后检查分片分布情况:
use emperor
db.getCollection("data_edit_log.45f7d791-f9df-4710-82be-6708479a1126").getShardDistribution()