|
手动迁移分片
一般情况下你不需要这么做,只有当一些特殊情况发生时,比如:
1)预分配空的集合时
2)在balancing时间窗之外
手动迁移的方法:- chunks:
- shard0000 2
- shard0001 2
- { "zipcode" : { "$minKey" : 1 } } -->> { "zipcode" : 10001 } on : shard0000 Timestamp(6, 0)
- { "zipcode" : 10001 } -->> { "zipcode" : 23772 } on : shard0001 Timestamp(6, 1)
- { "zipcode" : 23772 } -->> { "zipcode" : 588377 } on : shard0001 Timestamp(3, 2)
- { "zipcode" : 588377 } -->> { "zipcode" : { "$maxKey" : 1 } } on : shard0000 Timestamp(5, 1)
- mongos> db.adminCommand({moveChunk: "contact.people", find:{zipcode:10003}, to:"192.168.1.135:20002"})
- { "millis" : 2207, "ok" : 1 }
- mongos> sh.status()
- --- Sharding Status ---
- sharding version: {
- "_id" : 1,
- "version" : 3,
- "minCompatibleVersion" : 3,
- "currentVersion" : 4,
- "clusterId" : ObjectId("52ece49ae6ab22400d937891")
- }
- shards:
- { "_id" : "shard0000", "host" : "192.168.1.135:20002" }
- { "_id" : "shard0001", "host" : "192.168.1.135:20003" }
- databases:
- { "_id" : "admin", "partitioned" : false, "primary" : "config" }
- { "_id" : "test", "partitioned" : false, "primary" : "shard0000" }
- { "_id" : "contact", "partitioned" : true, "primary" : "shard0000" }
- contact.people
- shard key: { "zipcode" : 1 }
- chunks:
- shard0000 3
- shard0001 1
- { "zipcode" : { "$minKey" : 1 } } -->> { "zipcode" : 10001 } on : shard0000 Timestamp(6, 0)
- { "zipcode" : 10001 } -->> { "zipcode" : 23772 } on : shard0000 Timestamp(7, 0)
- { "zipcode" : 23772 } -->> { "zipcode" : 588377 } on : shard0001 Timestamp(7, 1)
- { "zipcode" : 588377 } -->> { "zipcode" : { "$maxKey" : 1 } } on : shard0000 Timestamp(5, 1)
-
- mongos>
复制代码 |
|