Definition定义
setAllowMigrationsPrevents the start of new automatic migrations on a collection, prevents in-flight range migrations (started manually or by the balancer) from committing, and excludes the collection from new balancer rounds.防止在集合上启动新的自动迁移,防止正在进行的范围迁移(手动或由平衡器启动)提交,并将集合排除在新的平衡器轮次之外。
Compatibility兼容性
This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:
- MongoDB Atlas
: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务
- MongoDB Enterprise
: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本 - MongoDB Community
: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本
Syntax语法
The command has the following syntax:该命令具有以下语法:
db.adminCommand(
{
setAllowMigrations: "<db>.<collection>",
allowMigrations: <true|false>
}
)Command Fields命令字段
The command takes the following parameters:该命令接受以下参数:
setAllowMigrations | string |
|
allowMigrations | boolean |
|
Behavior行为
setAllowMigrations requires the same privileges as 需要与moveChunk.moveChunk相同的权限。
Example示例
This operation prevents migrations on the 此操作可防止对store.inventory collection:store.inventory集合进行迁移:
db.adminCommand( {
setAllowMigrations: "store.inventory",
allowMigrations: false
} )