On this page本页内容
New in version 4.4.在版本4.4中新增。
setIndexCommitQuorum
Changes the minimum number of data-bearing members (i.e commit quorum), including the primary, that must complete an in-progress simultaneous index build before the primary marks those indexes as ready.更改数据承载成员的最小数量(即提交仲裁),包括主要成员,这些成员必须在主要成员将这些索引标记为就绪之前完成正在进行的同步索引构建。
The command has the following syntax:该命令具有以下语法:
db.runCommand({ setIndexCommitQuorum: <string>, indexNames: [ <document> ], commitQuorum: <int> | <string>, comment: <any> })
The command takes the following parameters:该命令采用以下参数:
setIndexCommitQuorum | string |
|
indexNames | array |
|
commitQuorum | int or string |
Supports the following values:
|
comment | any |
|
Each 副本集或分片集群中的每个mongod
in the replica set or sharded cluster must have featureCompatibilityVersion set to at least 4.4
to start index builds simultaneously across replica set members.mongod
必须将featureCompatibilityVersion设置为至少4.4
,才能在副本集成员之间同时启动索引构建。
MongoDB 4.4 running 运行featureCompatibilityVersion: "4.2"
builds indexes on the primary before replicating the index build to secondaries.featureCompatibilityVersion: "4.2"
的MongoDB 4.4在将索引构建复制到辅助数据库之前在主数据库上构建索引。
Issuing 发出setIndexCommitQuorum
has no effect on index builds started with commitQuorum of 0
.setIndexCommitQuorum
对commitQuorum为0
的索引生成没有影响。
Starting with MongoDB 4.4, index builds on a replica set or sharded cluster build simultaneously across all data-bearing replica set members. 从MongoDB 4.4开始,索引在副本集上构建,或在所有数据承载副本集成员上同时构建分片集群。For sharded clusters, the index build occurs only on shards containing data for the collection being indexed. 对于分片集群,索引构建仅发生在包含索引集合数据的分片上。The primary requires a minimum number of data-bearing 初选需要最少数量的数据承载voting
members (i.e commit quorum), including itself, that must complete the build before marking the index as ready for use. voting
成员(即提交法定人数),包括其自身,这些成员必须在将索引标记为可使用之前完成构建。See Index Builds in Replicated Environments for more information.有关详细信息,请参阅复制环境中的索引生成。
The following operation starts an index build of two indexes:以下操作启动两个索引的索引构建:
db.getSiblingDB("examples").invoices.createIndexes( [ { "invoices" : 1 }, { "fulfillmentStatus" : 1 } ] )
By default, index builds use 默认情况下,索引构建使用"votingMembers"
commit quorum, or all data-bearing voting replica set members. "votingMembers"
提交仲裁或所有数据承载的投票副本集成员。The following operation modifies the index build commit quorum to 以下操作将索引构建提交法定人数修改为"majority"
, or a simple majority of data-bearing voting members:."majority"
,或包含投票成员的简单多数:
db.getSiblingDB("examples").runCommand( { "setIndexCommitQuorum" : "invoices", "indexNames" : ["invoices_1", "fullfillmentStatus_1"], "commitQuorum" : "majority" } )
indexNames
must be the entire set of in-progress builds associated to a given index builder, i.e. indexNames
的索引必须是与给定索引生成器(即。createIndexes()
operation.createIndexes()
操作。indexNames
field specifies the names of the indexes. indexNames
字段指定索引的名称。