On this page本页内容
MongoDB 5.0 Released Jul 13, 2021MunGDB 5发布于2021年7月13日
Issues fixed:已修复问题:
Issues fixed:已修复问题:
mongos
服务器时出现意外的不可重试错误Issues fixed:已修复问题:
Issues fixed:已修复问题:
Issues fixed:已修复问题:
MongoDB version 5.0.1 is not recommended for production use due to critical issues SERVER-58936, WT-7984, and WT-7995, fixed in later versions. Use the latest available patch release version.
Issues fixed:已修复问题:
MongoDB version 5.0.0 is not recommended for production use due to critical issues SERVER-58936, WT-7984, and WT-7995, fixed in later versions. 由于SERVER-58936、WT-7984和WT-7995的关键问题,不建议生产使用MongoDB 5.0.0版,这些问题在更高版本中已修复。Use the latest available patch release version.使用最新的可用补丁发布版本。
The rest of this page provides the 5.0.0 release notes:本页其余部分提供了5.0.0发行说明:
MongoDB 5.0 introduces time series collections which efficiently store sequences of measurements over a period of time. MongoDB 5.0引入了时间序列集合,可以有效地存储一段时间内的测量序列。Compared to normal collections, storing time series data in time series collections improves query efficiency and reduces disk usage for your data and indexes.与普通集合相比,在时间序列集合中存储时间序列数据可以提高查询效率,并减少数据和索引的磁盘使用。
MongoDB 5.0 introduces the following aggregation operators:MongoDB 5.0引入了以下聚合运算符:
$count |
|
$dateAdd | |
$dateDiff | |
$dateSubtract | |
$dateTrunc | |
$getField | $getField to retrieve the value of fields with names that contain periods (. ) or start with dollar signs ($ ).$getField 检索名称中包含句点(. )的字段的值或者从美元符号($ )开始。 |
$rand | $rand method generates a random float value between 0 and 1 each time it is called. $rand 方法每次调用时都会生成一个介于0和1之间的随机浮点值。$sampleRate operator is based on $rand . $sampleRate 运算符基于$rand 。 |
$sampleRate | $sampleRate method to probabilistically select documents from a pipeline at a given rate.$sampleRate 方法,以按给定速率从管道中概率选择文档。 |
$setField | $setField to add, update, or remove fields with names that contain periods (. ) or start with dollar signs ($ ).$setField 添加、更新或删除名称中包含句点(. )或者从美元符号($ )开始。 |
$unsetField | $setField to remove fields with names that contain periods (. ) or that start with dollar signs ($ ).$setField 的别名,用于删除名称中包含句点(. )或者以美元符号($ )开头。 |
MongoDB 5.0 introduces the MongoDB 5.0引入了$setWindowFields
pipeline stage, allowing you to perform operations on a specified span of documents in a collection, known as a window. $setWindowFields
管道阶段,允许您对集合中指定范围的文档(称为“窗口”)执行操作。The operation returns the results based on the chosen window operator.该操作基于所选的窗口运算符返回结果。
For example, you can use the 例如,您可以使用$setWindowFields
stage to output the:$setWindowFields
阶段输出:
$expr
Starting in MongoDB 5.0, the 从MongoDB 5.0开始,放置在$eq
, $lt
, $lte
, $gt
, and $gte
operators placed in an $expr
operator can use indexes to improve performance.$expr
运算符中的$eq
、$lt
、$lte
、$gt
和$gte
运算符可以使用索引来提高性能。
$ifNull
Starting in MongoDB 5.0, you can specify multiple input expressions for the 从MongoDB 5.0开始,在返回替换表达式之前,可以为$ifNull
expression before returning a replacement expression.$ifNull
表达式指定多个输入表达式。
let
Option for Aggregationlet
选项Starting in MongoDB 5.0, the 从MongoDB 5.0开始,aggregate
command and db.collection.aggregate()
helper method have a let
option to specify a list of variables that can be used elsewhere in the aggregation pipeline. aggregate
命令和db.collection.aggregate()
助手方法有一个let
选项,用于指定可在聚合管道中其他地方使用的变量列表。This allows you to improve command readability by separating the variables from the query text.这允许您通过将变量与查询文本分离来提高命令的可读性。
$lookup
Starting in MongoDB 5.0, an aggregation pipeline 从MongoDB 5.0开始,聚合管道$lookup
stage supports concise correlated subqueries that improve joins between collections.$lookup
阶段支持简洁的相关子查询,从而改善集合之间的连接。
$lookup
Starting in MongoDB 5.0, for an uncorrelated subquery in a 从MongoDB 5.0开始,对于$lookup
pipeline stage containing a $sample
stage, the $sampleRate
operator, or the $rand
operator, the subquery is always run again if repeated. $lookup
管道阶段中包含$sample
阶段、$sampleRate
运算符或$rand
运算符的不相关子查询,如果重复,子查询始终会再次运行。Previously, depending on the subquery output size, either the subquery output was cached or the subquery was run again.以前,根据子查询输出的大小,可以缓存子查询输出,也可以再次运行子查询。
See Perform an Uncorrelated Subquery with 请参阅使用$lookup
.$lookup
执行不相关子查询。
MongoDB 5.0 adds the ability to configure auditing filters at runtime.MongoDB 5.0增加了在运行时配置审计筛选器的功能。
auditConfigPollingFrequencySecs | |
getAuditConfig | mongod and mongos .mongod 和mongos 检索审计配置。 |
setAuditConfig | mongod and mongos instances at runtime.mongod 和mongos 实例设置新的审计配置。 |
Starting in MongoDB 5.0:从MongoDB 5.0开始:
System event auditing has:系统事件审计具有:
Starting in MongoDB 5.0, Change Events contain the field 从MongoDB 5.0开始,Change事件包含updateDescription.truncatedArrays
to record array truncations.updateDescription.truncatedArrays
字段,用于记录数组截断。
Starting in MongoDB 5.0, multiple partial indexes can be created using the same key pattern as long as the partialFilterExpression fields do not express equivalent filters.从MongoDB 5.0开始,只要partialFilterExpression字段不表示等效的筛选器,就可以使用相同的键模式创建多个部分索引。
In earlier versions of MongoDB, creating multiple partial indexes is not allowed when using the same key pattern with different partialFilterExpressions.在早期版本的MongoDB中,当对不同的partialFilterExpressions使用相同的密钥模式时,不允许创建多个部分索引。
Starting in MongoDB 5.0, unique sparse and unique non-sparse indexes with the same key pattern can exist on a single collection.从MongoDB 5.0开始,具有相同键模式的唯一稀疏索引和唯一非稀疏索引可以存在于单个集合中。
Ready
Indexes During In-Progress Index BuildsReady
索引The 如果存在任何正在进行的索引生成,则db.collection.dropIndexes()
command cannot drop ready indexes if there are any in-progress index builds.db.collection.dropIndexes()
命令无法删除就绪索引。
When run on a MongoDB deployment, 在MongoDB部署上运行时,db.collection.validate()
attempts to fix multikey metadata inconsistencies of standalone deployments.db.collection.validate()
会尝试修复独立部署的多键元数据不一致。
geoHaystack
Index and the geoSearch
CommandgeoHaystack
索引和geoSearch
命令MongoDB 5.0 removes the deprecated geoHaystack index and MongoDB 5.0删除了不推荐使用的geoHaystack索引和geoSearch
command. geoSearch
命令。Use a 2d index with 使用带有$geoNear
or one of the supported geospatial query operators instead.$geoNear
的2d索引或受支持的地理空间查询运算符之一。
Upgrading your MongoDB instance to 5.0 and setting featureCompatibilityVersion to 将MongoDB实例升级到5.0并将5.0
will delete any pre-existing geoHaystack indexes.featureCompatibilityVersion
设置为5.0
将删除任何预先存在的geoHaystack索引。
The 当选项指定不正确时,db.collection.createIndex()
and db.collection.createIndexes()
operations have new error messages when options are specified incorrectly.db.collection.createIndex()
和db.collection.createIndexes()
操作会出现新的错误消息。
If a node in a replica set is cleanly shutdown or rolls back during an index build, the index build progress is now saved to disk. 如果副本集中的节点在索引生成期间完全关闭或回滚,则索引生成进度现在保存到磁盘。When the server restarts, index creation resumes from the saved position.服务器重新启动时,索引创建将从保存的位置恢复。
reIndex
Starting in MongoDB 5.0, the 从MongoDB 5.0开始,reIndex
command and the db.collection.reIndex()
shell method may only be run on standalone instances.reIndex
命令和db.collection.reIndex()
shell方法只能在独立实例上运行。
Starting in MongoDB 5.0, these database commands and 从MongoDB 5.0开始,删除以下数据库命令和mongo
shell helper methods are removed:mongo
shell 助手方法:
db.collection.ensureIndex() | db.collection.createIndex() |
db.resetError() | |
resetError | |
shardConnPoolStats | connPoolStats |
unsetSharding | |
geoSearch | $geoNear |
config.transactions
config.transactions
上的非事务读取Starting in MongoDB 5.0, non-transaction reads are not allowed on the 从MongoDB 5.0开始,config.transactions
collection with the following read concerns and options:config.transactions
集合上不允许进行非事务读取,具有以下读取问题和选项:
"snapshot"
"majority"
and the afterClusterTime option is set"majority"
和afterClusterTime选项已设置"majority"
within a causally consistent session"majority"
时hello
Starting in MongoDB 5.0 (and 4.4.2, 4.2.10, 4.0.21, and 3.6.21), the 从MongoDB 5.0(以及4.4.2、4.2.10、4.0.21和3.6.21)开始,hello
command and the db.hello()
method were introduced as replacements for the isMaster
command and the db.isMaster()
method. hello
命令和db.hello()
方法被引入,以替代isMaster
命令和db.isMaster()
方法。The new topology metric 新的拓扑度量connections.exhaustHello
tracks this in connections
.connections.exhaustHello
在connections
中跟踪这一点。
Starting in MongoDB 5.0, 从MongoDB 5.0开始,mongod
and mongos
enter a quiesce period to allow any ongoing database operations to complete before shutting down.mongod
和mongos
进入一个静止期,允许任何正在进行的数据库操作在关闭之前完成。
members[n]._id
Valuesmembers[n]._id
值的限制删除Starting in MongoDB 5.0, the 从MongoDB 5.0开始,members[n]._id
field may be any integer value greater than or equal to 0
. members[n]._id
字段可以是大于或等于0
的任何整数值。Previously, this value was limited to an integer between 以前,该值被限制为0
and 255
inclusive.0
到255
(包含0
和255
)之间的整数。
enableMajorityReadConcern
Starting in MongoDB 5.0, 从MongoDB 5.0开始,由于存储引擎的改进,enableMajorityReadConcern
and --enableMajorityReadConcern
cannot be changed and are always set to true
due to storage engine improvements.enableMajorityReadConcern
和--enableMajorityReadConcern
无法更改,并且始终设置为true
。
In earlier versions of MongoDB, 在早期版本的MongoDB中,enableMajorityReadConcern
and --enableMajorityReadConcern
are configurable and can be set to false
to prevent storage cache pressure from immobilizing a deployment with a three-member primary-secondary-arbiter (PSA) architecture.enableMajorityReadConcern
和--enableMajorityReadConcern
是可配置的,可以设置为false
,以防止存储缓存压力阻止使用三成员主从仲裁器(PSA)体系结构的部署。
If you are using a three-member primary-secondary-arbiter (PSA) architecture, the write concern 如果您使用的是三成员主从仲裁器(PSA)体系结构,那么如果次要仲裁器不可用或滞后,写问题"majority"
can cause performance issues if a secondary is unavailable or lagging. "majority"
可能会导致性能问题。See Mitigate Performance Issues with PSA Replica Set for advice on how to mitigate these issues.有关如何缓解这些问题的建议,请参阅缓解PSA副本集的性能问题。
Starting in MongoDB 5.0, you can use the new 从MongoDB 5.0开始,您可以使用新的replWriterMinThreadCount
server parameter to configure the timeout of idle threads in the thread pool for parallel execution of replication operations. replWriterMinThreadCount
服务器参数来配置线程池中空闲线程的超时,以便并行执行复制操作。When 当replWriterMinThreadCount
is configured with a value less than replWriterThreadCount
, idle threads above replWriterMinThreadCount
are timed out.replWriterMinThreadCount
配置为小于replWriterThreadCount
的值时,高于replWriterMinThreadCount
的空闲线程将超时。
When reconfiguring primary-secondary-arbiter (PSA) replica sets or changing to a PSA architecture, it is now in some cases required to perform the reconfiguration in a two-step change. 当重新配置主从仲裁器(PSA)副本集或更改为PSA体系结构时,在某些情况下,现在需要以两步更改的方式执行重新配置。MongoDB 5.0 introduces the MongoDB 5.0引入了rs.reconfigForPSASet()
method which performs both steps. rs.reconfigForPSASet()
方法,该方法执行这两个步骤。If you cannot use the helper method, follow the procedure in Modify PSA Replica Set Safely.如果无法使用助手方法,请按照安全修改PSA副本集中的步骤操作。
maxNumSyncSourceChangesPerHour
determines how many sync source changes can happen per hour before the node temporarily stops re-evaluating a sync source. 确定在节点临时停止重新评估同步源之前,每小时可以发生多少次同步源更改。This parameter will not prevent a node from starting to sync from another node if it doesn't have a sync source.如果一个节点没有同步源,此参数不会阻止该节点开始与另一个节点同步。
enableOverrideClusterChainingSetting
Starting in MongoDB 5.0.2 (and 4.2.16 and 4.4.8), you can set the new 从MongoDB 5.0.2(以及4.2.16和4.4.8)开始,您可以将新的enableOverrideClusterChainingSetting
server parameter to true
to allow secondary members to replicate data from other secondary members even if settings.chainingAllowed
is false
.enableOverrideClusterChainingSetting
服务器参数设置为true
,以允许辅助成员从其他辅助成员复制数据,即使settings.chainingAllowed
为false
。
Starting in MongoDB 5.0, you may now rotate the following TLS certificates on demand without first needing to stop your running 从MongoDB 5.0开始,您现在可以根据需要轮换以下TLS证书,而无需首先停止运行mongod
or mongos
instance:mongod
或mongos
实例:
TLS Certificates
CRL (Certificate Revocation List) files
CA (Certificate Authority) files
To rotate these certificates, replace the certificate files on your filesystem with updated versions, then use the 要旋转这些证书,请用更新的版本替换文件系统上的证书文件,然后使用rotateCertificates
command or the db.rotateCertificates()
shell method to trigger certificate rotation.rotateCertificates
命令或db.rotateCertificates()
shell方法触发证书旋转。
Rotating certificates in this manner does not require downtime, and does not drop any active remote connections.以这种方式旋转证书不需要停机,也不会中断任何活动的远程连接。
See Online Certificate Rotation for full details.有关详细信息,请参阅在线证书轮换。
MongoDB 5.0 introduces the MongoDB 5.0引入了opensslCipherSuiteConfig
parameter to enable configuration of the supported cipher suites OpenSSL should permit when using TLS 1.3 encryption.opensslCipherSuiteConfig
参数,以启用在使用TLS 1.3加密时OpenSSL应允许的受支持密码套件的配置。
Starting in MongoDB 5.0, 从MongoDB 5.0开始,mongod
and mongos
now issue a startup warning when their certificates do not include a Subject Alternative Name attribute.mongod
和mongos
现在会在其证书不包含Subject Alternative Name属性时发出启动警告。
The following platforms do not support common name validation:以下平台不支持通用名称验证:
Clients using these platforms will not authenticate to MongoDB servers that use x.509 certificates whose hostnames are specified by CommonName attributes.使用这些平台的客户端不会向使用x.509证书的MongoDB服务器进行身份验证,该证书的主机名由CommonName属性指定。
MongoDB 5.0 introduces the MongoDB 5.0引入了由applyOps
privilege action which is inherited by dbAdminAnyDatabase
.dbAdminAnyDatabase
继承的applyOps
权限操作。
The applyOps
action permits users to run the applyOps
database command.applyOps
操作允许用户运行applyOps
数据库命令。
The ideal shard key allows MongoDB to distribute documents evenly throughout the cluster while facilitating common query patterns. 理想的切分密钥允许MongoDB在集群中均匀分布文档,同时促进常见的查询模式。A suboptimal shard key can lead to performance or scaling issues due to uneven data distribution. 由于数据分布不均匀,次优的分片密钥可能会导致性能或扩展问题。Starting in MongoDB 5.0, you can use the 从MongoDB 5.0开始,您可以使用reshardCollection
command to change the shard key for a collection to change the distribution of your data across your cluster.reshardCollection
命令更改集合的分片键,以更改数据在集群中的分布。
currentOp
Starting in MongoDB 5.0, the 从MongoDB 5.0开始,$currentOp
aggregation stage (and the currentOp
command and db.currentOp()
shell method) include additional information about the status of ongoing resharding operations for the resharding coordinator and the donor and recipient shards.$currentOp
聚合阶段(以及currentOp
命令和db.currentOp()
shell方法)包括有关重新存储协调器、捐赠者和接收者分片正在进行的重新存储操作状态的附加信息。
db.currentOp
mongosh
mongosh
中使用聚合阶段Starting in MongoDB 5.0, the 从MongoDB 5.0开始,在使用mongosh运行助手方法$currentOp
aggregation stage is used when running the helper method db.currentOp()
with mongosh
.db.currentOp()
时使用$currentOp
聚合阶段。
mongos
/ mongod
Starting in MongoDB 5.0 (also available starting in 4.4.5 and 4.2.13), MongoDB adds the parameter option 从MongoDB 5.0开始(也可以从4.4.5和4.2.13开始使用),MongoDB添加了参数选项"automatic"
as the new default for the ShardingTaskExecutorPoolReplicaSetMatching
. "automatic"
,作为ShardingTaskExecutorPoolReplicaSetMatching
的新默认值。When set for a 为mongos
, the instance follows the behavior specified for the "matchPrimaryNode"
option. mongos
设置时,实例遵循为"matchPrimaryNode"
选项指定的行为。When set for a 为mongod
, the instance follows the behavior specified for the "disabled"
option.mongod
设置时,实例将遵循为"disabled"
选项指定的行为。
renameCollection
Starting in MongoDB 5.0, you can use the 从MongoDB 5.0开始,可以使用renameCollection
command to change the name of a sharded collection.renameCollection
命令更改分片集合的名称。
When renaming a sharded or unsharded collection in a sharded cluster, the source and target collections are exclusively locked on every shard. 重命名分片集群中的分片集合或未分片集合时,源集合和目标集合在每个分片上都被独占锁定。Subsequent operations on the source and target collections must wait until the rename operation completes.对源集合和目标集合的后续操作必须等待重命名操作完成。
movePrimary
Starting in MongoDB 5.0, when using the 从MongoDB 5.0开始,当使用movePrimary
command to remove a shard from a sharded cluster, writes to the original shard will generate an error message.movePrimary
命令从分片集群中删除分片时,写入原始分片将生成错误消息。
Starting in MongoDB 5.0, documents in the 从MongoDB 5.0开始,用于拆分和合并操作的config.changelog
collection for split and merge operations contain an owningShard
field. config.changelog
集合中的文档包含owningShard
字段。The owningShard
field shows the shardId
of the shard that owns the chunks that were split or merged.owningShard
字段显示拥有被拆分或合并的块的分片的shardId
。
The owningShard
field helps identify shards where split or merge operations frequently occur.owningShard
字段有助于识别经常发生拆分或合并操作的分片。
maxCatchUpPercentageBeforeBlockingWrites
Starting in MongoDB 5.0 (and 4.4.7, 4.2.15, 4.0.26), you can set the 从MongoDB 5.0(以及4.4.7、4.2.15、4.0.26)开始,您可以设置maxCatchUpPercentageBeforeBlockingWrites
to specify the maximum allowed percentage of data not yet migrated during a moveChunk
operation when compared to the total size (in MBs) of the chunk being transferred.maxCatchUpPercentageBeforeBlockingWrites
,以指定在moveChunk
操作期间,与正在传输的块的总大小(以MB为单位)相比,尚未迁移的数据的最大允许百分比。
This parameter can affect the behavior of:此参数可能会影响以下对象的行为:
moveChunk
moveChunk
commands to evenly distribute chunks across shards. moveChunk
命令,在分片上均匀分布块。mongosh
The mongo
shell has been deprecated in MongoDB v5.0. mongo
Shell在MongoDB v5中已被弃用。0The replacement shell is 替换的外壳是mongosh
. mongosh
。The legacy 遗留的mongo
shell will be removed in a future release.mongo
shell将在未来的版本中删除。
Shell packaging also changes in MongoDB v5.0. 在MongoDB v5中,Shell的包装也发生了变化。0Refer to the installation instructions for further details.有关更多详细信息,请参阅安装说明。
Starting in MongoDB 5.0 (and MongoDB 4.4.5), the Google Cloud Platform KMS and Azure Key Vault are supported in both 从MongoDB 5.0(和MongoDB 4.4.5)开始,Google云平台KMS和Azure密钥库在mongosh
and the legacy mongo
shell as Key Management Service (KMS) providers for Client-Side Field Level Encryption.mongosh
和传统mongo
shell中都支持,作为客户端字段级加密的密钥管理服务(KMS)提供程序。
Using a KMS, you can centrally and securely store Customer Master Keys (CMKs), which are used to encrypt and decrypt data encryption keys as part of the client-side field level encryption workflow.使用KMS,您可以集中且安全地存储客户主密钥(CMK),作为客户端字段级加密工作流的一部分,这些密钥用于加密和解密数据加密密钥。
In addition, a configured KMS allows for the use of Automatic Field Decryption of data fields when used with MongoDB Enterprise.此外,配置的KMS允许在与MongoDB Enterprise一起使用时使用数据字段的自动字段解密。
Instructions are available for both shells:这两种外壳都有说明:
"snapshot"
"snapshot"
的扩展支持Starting in MongoDB 5.0, read concern 从MongoDB 5.0开始,在一级和二级上的多文档事务之外的一些读取操作支持读取关注点"snapshot"
is supported for some read operations outside of multi-document transactions on primaries and secondaries."snapshot"
。
minSnapshotHistoryWindowInSeconds
Starting in MongoDB 5.0, you can use the 从MongoDB 5.0开始,可以使用minSnapshotHistoryWindowInSeconds
parameter to control how long WiredTiger keeps the snapshot history.minSnapshotHistoryWindowInSeconds
参数来控制WiredTiger保留快照历史记录的时间。
coordinateCommitReturnImmediatelyAfterPersistingDecision
Starting in MongoDB 5.0, the new server parameter 从MongoDB 5.0开始,新的服务器参数coordinateCommitReturnImmediatelyAfterPersistingDecision
controls when transaction commit decisions are returned to the client. coordinateCommitReturnImmediatelyAfterPersistingDecision
控制何时将事务提交决策返回给客户端。In previous versions of MongoDB, the shard transaction coordinator waited for all members to acknowledge a multi-document transaction commit before returning the commit decision to the client.在以前版本的MongoDB中,分片事务协调器等待所有成员确认多文档事务提交,然后将提交决定返回给客户端。
Starting in February 2022, the "Versioned API" terminology was changed to "Stable API". All concepts and features remain the same with this naming change.从2022年2月开始,“版本化API”术语改为“稳定API”。所有的概念和功能在命名上都保持不变。
Starting in MongoDB 5.0, the implicit delete operations of replica setcapped collections are processed by the secondary members.从MongoDB 5.0开始,复制集封顶集合的隐式删除操作由次要成员处理。
$lookup
Pipeline Stage$lookup
管道阶段查询的执行计划统计信息MongoDB 5.0 adds execution plan statistics for queries that use a MongoDB 5.0为使用$lookup
pipeline stage.$lookup
管道阶段的查询添加了执行计划统计信息。
$
) and (.
) in Field Names$
)和(.
)的处理MongoDB 5.0 adds improved support for field names that are (MongoDB 5.0增加了对前缀为($
) prefixed or that contain (.
) characters. $
)或包含($
)字符的字段名的改进支持。The validation rules for storing data have been updated to make it easier to work with data sources that use these characters.存储数据的验证规则已经更新,以便更容易使用使用这些字符的数据源。
Starting in MongoDB 5.0, once the Cluster Wide Write Concern (CWWC) is set via the 从MongoDB 5.0开始,一旦通过setDefaultRWConcern
command the write concern cannot be unset.setDefaultRWConcern
命令设置了集群范围的写关注点(CWWC),就不能取消设置写关注点。
Starting in MongoDB 5.0, the implicit default write concern is 从MongoDB 5.0开始,隐式的默认写入关注点是w: majority
. w: majority
。However, special considerations are made for deployments containing arbiters:但是,对于包含仲裁器的部署,需要特别考虑:
{ w: 1 }
.{w:1}
。{ w: "majority" }
.{ w: "majority" }
。Specifically, MongoDB uses the following formula to determine the default write concern:具体来说,MongoDB使用以下公式来确定默认写入关注点:
if [ (#arbiters > 0) AND (#non-arbiters <= majority(#voting-nodes)) ] defaultWriteConcern = { w: 1 } else defaultWriteConcern = { w: "majority" }
For example, consider the following deployments and their respective default write concerns:例如,考虑以下部署和它们各自的默认写入关注点:
2 | 1 | 3 | 2 | { w: 1 } |
4 | 1 | 5 | 3 | { w: "majority" } |
In the first example:在第一个例子中:
{ w: 1 }
.{w:1}
。In the second example:在第二个例子中:
{ w: "majority" }
.{ w: "majority" }
。
The { w: "majority" }
default write concern provides a stronger durability guarantee in the event of an election, or if replica set members become unavailable.{ w: "majority" }
默认写入关注点在选举或副本集成员不可用时提供了更强的持久性保证。
The { w: "majority" }
write concern may impact performance since writes will only be acknowledged once a calculated majority of replica set members have executed and persisted the write to disk. { w: "majority" }
写入关注点可能会影响性能,因为只有在计算出多数副本集成员执行并持久化磁盘写入后,才会确认写入。If your application relies on performance-sensitive writes, you can use the 如果应用程序依赖于对性能敏感的写操作,则可以使用setDefaultRWConcern
command to explicitly set the default write concern for improved performance at the cost of data durability guarantees. setDefaultRWConcern
命令显式设置默认写操作,以提高性能,同时牺牲数据持久性保证。You can also set the write concern at the individual operation level for performance-critical writes. 还可以在单个操作级别为性能关键型写入设置写入关注点。See your driver documentation for details.有关详细信息,请参阅驱动程序文档。
mongosShutdownTimeoutMillisForSignaledShutdown
Starting in MongoDB 5.0, the new parameter 从MongoDB 5.0开始,新参数mongosShutdownTimeoutMillisForSignaledShutdown
specifies the time in milliseconds to wait for any ongoing database operations to complete before initiating a shutdown of mongos
.mongosShutdownTimeoutMillisForSignaledShutdown
指定在启动mongos
关闭之前等待任何正在进行的数据库操作完成的时间(以毫秒为单位)。
zstd
Compression Levelzstd
压缩级别MongoDB 5.0 introduces the MongoDB 5.0引入了zstdCompressionLevel
configuration file option which allows for configurable compression levels when blockCompressor
is set to zstd
.zstdCompressionLevel
配置文件选项,当blockCompressor
设置为zstd
时,该选项允许配置压缩级别。
Starting in MongoDB 5.0, the following read operations are not blocked when another operation holds an exclusive (X) write lock on the collection:从MongoDB 5.0开始,当另一个操作对集合持有独占(X)写锁时,以下读取操作不会被阻止:
When writing to a collection, 在写入集合时,mapReduce
and aggregate
hold an intent exclusive (IX) lock. mapReduce
和aggregate
持有一个intent exclusive(IX)锁。Therefore, if an exclusive X lock is already held on a collection, 因此,如果集合上已持有独占X锁,则会阻止mapReduce
and aggregate
write operations are blocked.mapReduce
和aggregate
写入操作。
MongoDB 5.0 adds detailed explanations when a document fails schema validation.MongoDB 5.0在文档未能通过模式验证时添加了详细的解释。
validate
Commandvalidate
命令中的修复选项Starting in MongoDB 5.0, the 从MongoDB 5.0开始,validate
command and db.collection.validate()
helper method have a new repair option for repairing a collection that has inconsistencies.validate
命令和db.collection.validate()
助手方法有一个新的repair
选项,用于修复存在不一致的集合。
The validate
command and db.collection.validate()
helper method also return a new repaired
boolean value that is true
if the collection was repaired.validate
命令和db.collection.validate()
助手方法还返回一个新的repaired
布尔值,如果该集合已修复,则该值为true
。
validate
Command Reports Document Schema Violationsvalidate
命令报告文档架构冲突Starting in MongoDB 5.0, 从MongoDB 5.0开始,validate
and db.collection.validate()
validates documents in a collection. validate
和db.collection.validate()
验证集合中的文档。The commands report if any schema validation rules are violated.如果违反任何架构验证规则,这些命令都会报告。
mongod
mongod
的维修选项Starting in MongoDB 5.0, the 从MongoDB 5.0开始,--repair
option for mongod
validates the collections to find any inconsistencies and fixes them if possible, which avoids rebuilding the indexes. mongod
的--repair
选项会验证集合,以发现任何不一致,并在可能的情况下修复它们,从而避免重建索引。See the 有关用法和限制,请参阅--repair
option for usage and limitations.--repair
选项。
corruptRecords
Starting in MongoDB 5.0, the 从MongoDB 5.0开始,validate
command and db.collection.validate()
helper method return a new corruptRecords
field that contains an array of RecordId
values for corrupt documents.validate
命令和db.collection.validate()
助手方法返回一个新的corruptRecords
字段,该字段包含损坏文档的RecordId
值数组。
maxValidateMemoryUsageMB
Starting in MongoDB 5.0, the 从MongoDB 5.0开始,setParameter
command has a new maxValidateMemoryUsageMB
parameter, which sets the maximum memory usage for the validate
command.setParameter
命令有一个新的maxValidateMemoryUsageMB
参数,用于设置validate
命令的最大内存使用量。
findChunksOnConfigTimeoutMS
Starting in MongoDB 5.0, you can use the 从MongoDB 5.0开始,可以使用findChunksOnConfigTimeoutMS
parameter to change the timeout for find operations on chunks
.findChunksOnConfigTimeoutMS
参数更改块上查找操作的超时。
filter
Optionfilter
选项Starting in MongoDB 5.0, you can set a 从MongoDB 5.0开始,您可以为数据库探查器设置一个filter
option for the database profiler to determine which operations are profiled and logged. filter
选项,以确定哪些操作被探查和记录。You can use the 可以使用filter
expression in place of the slowms
and sampleRate
profiler options.filter
表达式代替slowms
和sampleRate
探查器选项。
See:请参阅:
Starting in MongoDB 5.0 (also available starting in 4.4.2, 4.2.12, and 4.0.22), changes made to the database profiler 从MongoDB 5.0开始(也可以从4.4.2、4.2.12和4.0.22开始),使用level
, slowms
, sampleRate
, or filter
using the profile
command or db.setProfilingLevel()
wrapper method are recorded in the log file
.profile
命令或db.setProfilingLevel()
包装方法对数据库探查器level
、slowms
、sampleRate
或filter
所做的更改将记录在日志文件中。
Starting in MongoDB 5.0, when auditing is enabled, you may now rotate the server and audit logs independently using the 从MongoDB 5.0开始,启用审计后,现在可以使用logRotate
command. logRotate
命令独立地旋转服务器和审计日志。Previously, 之前,logRotate
would rotate the two logs together.logRotate
会将两个日志一起旋转。
remote
Field in Slow Operation Logsremote
字段Starting in MongoDB 5.0, slow operation log messages include a 从MongoDB 5.0开始,慢速操作日志消息包括一个指定客户端IP地址的remote
field specifying client IP address.remote
字段。
remoteOpWaitMillis
Starting in MongoDB 5.0, you can use the remoteOpWaitMillis log field to obtain the wait time for results from shards.从MongoDB 5.0开始,可以使用remoteOpWaitMillis日志字段获取分片结果的等待时间。
resolvedViews
Starting in MongoDB 5.0, log messages for slow queries on views include a 从MongoDB 5.0开始,针对视图的慢速查询的日志消息包括一个包含视图详细信息的resolvedViews
field that contains the view details.resolvedViews
字段。
let
Optionlet
选项定义变量Starting in MongoDB 5.0, the following commands have a 从MongoDB 5.0开始,以下命令有一个let
option to define a list of variables. let
选项来定义变量列表。This allows you to improve command readability by separating the variables from the query text.这允许您通过将变量与查询文本分离来提高命令的可读性。
find
commandfindAndModify
command and corresponding db.collection.findAndModify()
shell helperfindAndModify
命令和相应的db.collection.findAndModify()
shell助手update
db.collection.update()
shelldelete
db.collection.remove()
shellThe update
command also has a c
field to define a list of variables.update
命令还有一个c
字段,用于定义变量列表。
Starting in MongoDB 5.0, the 从MongoDB 5.0开始,如果为选项指定了空映射文档(即空字符串或空数组),userToDNMapping
configuration file option and the --ldapUserToDNMapping
command line option for mongod
/ mongos
and mongoldap
now map the authenticated username as the LDAP DN by default if an empty mapping document (i.e. an empty string or empty array) is specified to the option. mongod
/mongos
和mongoldap
的userToDNMapping
配置文件选项和--ldapUserToDNMapping
命令行选项现在默认情况下将经过身份验证的用户名映射为LDAP DN。Previously, providing an empty mapping document would cause mapping to fail.以前,提供空映射文档会导致映射失败。
dbStats
Free Space StatisticsdbStats
可用空间统计信息Starting in MongoDB 5.0, the 从MongoDB 5.0开始,dbStats
command outputs these additional statistics:dbStats
命令输出以下附加统计信息:
freeStorageSize
)freeStorageSize
)indexFreeStorageSize
)indexFreeStorageSize
)totalFreeStorageSize
)totalFreeStorageSize
)serverStatus
serverStatus
includes the following new fields in its output:在其输出中包括以下新字段:
metrics.commands.update.pipeline
(Also available in 4.4.2+, 4.2.11+)metrics.commands.update.arrayFilters
(Also available in 4.4.2+, 4.2.11+)metrics.commands.findAndModify.pipeline
(Also available in 4.4.2+, 4.2.11+)metrics.commands.findAndModify.arrayFilters
(Also available in 4.4.2+, 4.2.11+)metrics.dotsAndDollarsFields
metrics.operatorCounters
readConcernCounters
readConcernCounters
replaces opReadConcernCounters
)readConcernCounters
替换opReadConcernCounters
)connections.threaded
shardingStatistics.resharding
network.serviceExecutors
metrics.cursor.moreThanOneBatch
getMore
command)getMore
命令检索其他批)metrics.cursor.totalOpened
security.authentication.saslSupportedMechsReceived
, which reports the number of times a hello
request includes a valid hello.saslSupportedMechs
field.repl
primaryOnlyServices
document that contains additional information about services that only run on replica set primaries.primaryOnlyServices
文档,其中包含有关仅在副本集Primary上运行的服务的附加信息。Starting in MongoDB 5.0 (and 4.4.3, 4.2.12, 4.0.23, and 3.6.23), the plan cache will save full 从MongoDB 5.0(以及4.4.3、4.2.12、4.0.23和3.6.23)开始,只有当所有集合的计划缓存的累积大小小于0.5 GB时,计划缓存才会保存完整的计划缓存项。plan cache
entries only if the cumulative size of the plan caches
for all collections is lower than 0.5 GB. When the cumulative size of the 当所有集合的计划缓存的累积大小超过此阈值时,将存储其他计划缓存项,而不存储特定的调试信息。plan caches
for all collections exceeds this threshold, additional plan cache
entries are stored without certain debug information.
The estimated size in bytes of a 计划缓存项的估计大小(以字节为单位)可在plan cache
entry is available in the output of $planCacheStats
.$planCacheStats
的输出中获得。
Starting in MongoDB 5.0 (and 4.4.8), cursors created within a client session close when the corresponding server session ends with the 从MongoDB 5.0(和4.4.8)开始,当相应的服务器会话以killSessions
command, if the session times out, or if the client has exhausted the cursor. killSessions
命令结束时,如果会话超时,或者如果客户端耗尽了游标,则在客户端会话中创建的游标将关闭。See Iterate a Cursor in 请参见在mongosh
.mongosh
中迭代游标。
validateDBMetadata
CommandvalidateDBMetadata
命令MongoDB 5.0 adds the MongoDB 5.0添加了validateDBMetadata
command. validateDBMetadata
命令。The validateDBMetadata
command checks that the stored metadata of a database or a collection is valid within a particular API version.validateDBMetadata
命令检查存储的数据库或集合的元数据在特定API版本内是否有效。
MongoDB 5.0 introduces the following minimum microarchitecture requirements:MongoDB 5.0引入了以下最低微体系结构要求:
CPU | |
---|---|
Intel x86_64 |
|
AMD x86_64 | MongoDB 5.0 requires AMD Bulldozer or later. |
ARM arm64 | MongoDB 5.0 requires ARMv8.2-A or later. |
MongoDB v5.0 is not supported on 不满足这些最低微体系结构要求的x86_64
or arm64
platforms that do not meet these minimum microarchitecture requirements.x86_64
或arm64
平台不支持MongoDB v5.0。
See x86_64 Platform Support for more information.有关更多信息,请参阅x86_64平台支持。
MongoDB 5.0 removes support for the following platforms:MongoDB 5.0取消了对以下平台的支持:
See Supported Platforms for the full list of platforms and architectures supported in MongoDB 5.0.有关MongoDB 5.0中支持的平台和体系结构的完整列表,请参阅支持的平台。
Some changes can affect compatibility and may require user actions. 某些更改可能会影响兼容性,并可能需要用户操作。For a detailed list of compatibility changes, see Compatibility Changes in MongoDB 5.0.有关兼容性更改的详细列表,请参阅MongoDB 5.0中的兼容性更改。
To upgrade to MongoDB 5.0 from a 4.4 deployment, the 4.4 deployment must have 要从4.4部署升级到MongoDB 5.0,4.4部署必须将featureCompatibilityVersion
set to 4.4
. featureCompatibilityVersion
设置为4.4
。To check the version:要检查版本,请执行以下操作:
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
To upgrade to MongoDB 5.0, refer to the upgrade instructions specific to your MongoDB deployment:要升级到MongoDB 5.0,请参阅特定于MongoDB部署的升级说明:
If you need guidance on upgrading to 5.0, MongoDB offers major version upgrade services to help ensure a smooth transition without interruption to your MongoDB application.如果您需要升级到5.0的指导,MongoDB提供主要的版本升级服务,以帮助确保顺利过渡到MongoDB应用程序,而不会中断。
To download MongoDB 5.0, go to the MongoDB Download Center.要下载MongoDB 5.0,请访问MongoDB下载中心。
5.0.0 | SERVER-58171granularity parameter cannot be modified after the collection is created.granularity (粒度)参数。 | |
5.0.0 | SERVER-58392 |
To report an issue, see https://github.com/mongodb/mongo/wiki/Submit-Bug-Reports for instructions on how to file a JIRA ticket for the MongoDB server or one of the related projects.要报告问题,请参阅https://github.com/mongodb/mongo/wiki/Submit-Bug-Reports以了解有关如何为MongoDB服务器或其中一个相关项目提交JIRA票证的说明。