MongoDB 分片之间的迁移数据
Migration data between shards with MongoDB
我有下面的 MongoDB 分片,配置如下:
- 一台前端服务器
- 一个配置服务器
- 2 个分片:shard01 和 shard02
- 分片集合:collection01
- 2 个区域/2 个范围:
- zone01 { "num" : 0 } -->> { "num" : 10 }
- zone02 { "num" : 11 } -->> { "num" : 20 }
是否可以将数据从 zone01 迁移到 zone02?
我试图删除范围并重新创建它,但我在两个 shards/zones.
中都得到了重复的数据
事实上,在数据从 shard01 逐步移动到 shard02 的几次之后,迁移过程正在进行中,下面是我使用的命令:
1- 删除当前范围
sh.removeRangeFromZone("db2017.collection01", { num: 0 }, { num: 10 })
sh.removeRangeFromZone("db2017.collection01", { num: 11 }, { num: 20 })
2- 重新创建具有不同区域的新范围:
sh.addTagRange("db2017.collection01", { num: 1 }, { num: 10 }, "zone02")
sh.addTagRange("db2017.collection01", { num: 11 },{ num: 20 }, "zone01")
给你一些时间 MongoDB 它会自动在碎片之间迁移你的数据。
我有下面的 MongoDB 分片,配置如下:
- 一台前端服务器
- 一个配置服务器
- 2 个分片:shard01 和 shard02
- 分片集合:collection01
- 2 个区域/2 个范围:
- zone01 { "num" : 0 } -->> { "num" : 10 }
- zone02 { "num" : 11 } -->> { "num" : 20 }
是否可以将数据从 zone01 迁移到 zone02?
我试图删除范围并重新创建它,但我在两个 shards/zones.
中都得到了重复的数据事实上,在数据从 shard01 逐步移动到 shard02 的几次之后,迁移过程正在进行中,下面是我使用的命令:
1- 删除当前范围
sh.removeRangeFromZone("db2017.collection01", { num: 0 }, { num: 10 })
sh.removeRangeFromZone("db2017.collection01", { num: 11 }, { num: 20 })
2- 重新创建具有不同区域的新范围:
sh.addTagRange("db2017.collection01", { num: 1 }, { num: 10 }, "zone02")
sh.addTagRange("db2017.collection01", { num: 11 },{ num: 20 }, "zone01")
给你一些时间 MongoDB 它会自动在碎片之间迁移你的数据。