Database Manual / Reference / Database Commands / Sharding

setAllowMigrations (database command数据库命令)

Definition定义

setAllowMigrations
Prevents 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:该命令接受以下参数:

Field字段Type类型Description描述
setAllowMigrationsstring

The collection to modify.要修改的集合。

allowMigrationsboolean

If false:如果为false

  • MongoDB prevents new automatic migrations on the collectionMongoDB阻止对集合进行新的自动迁移
  • in-flight range migrations will not be committed飞行中的范围迁移将不会进行提交。
  • the collection will be excluded from new balancer rounds该集合将被排除在新的平衡器轮次之外

If true:如果为true

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
} )