定义
sh.enableMigrations(namespace)Enables migrations for the specified namespace of the sharded collection, but does not start chunk migrations. The balancer includes the collection you pass to
sh.enableMigrations()in migration operations the next time it runs. For more information on chunk migrations, see Manage Sharded Cluster Balancer.重要
You can only run
sh.enableMigrations()on amongosinstance. If you runsh.enableMigrations()on amongodinstance, the method returns an error.The
sh.enableMigrations()method has the following parameter:Parameter类型说明namespace字符串
集合的命名空间。
兼容性
此方法可用于以下环境中托管的部署:
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
注意
您可以使用 sh.status() 验证迁移状态,这会显示每个集合的 allowMigrations字段。