Docs HomeMongoDB Manual

Release Notes for MongoDB 6.0 (Stable Release)MongoDB 6.0发布说明(稳定版)

This page describes changes and new features introduced in MongoDB 6.0.本页介绍MongoDB 6.0中引入的更改和新功能。

MongoDB 6.0 is a Major Release, which means that it is supported for both MongoDB Atlas and on-premises deployments. MongoDB 6.0是一个主要版本,这意味着它同时支持MongoDB Atlas和本地部署。MongoDB 6.0 includes changes introduced in MongoDB Rapid Releases 5.1, 5.2, and 5.3. MongoDB 6.0包括在MongoDB Rapid Release 5.1、5.2和5.3中引入的更改。This page describes changes introduced in those Rapid Releases and MongoDB 6.0.本页介绍了Rapid Release和MongoDB 6.0中引入的更改。

To learn more about the differences between Major and Rapid releases, see MongoDB Versioning.要了解更多关于Major和Rapid版本之间的差异,请参阅MongoDB版本控制

Warning

Past Release Limitations过去的发布限制

Some past releases have critical issues. 过去的一些版本存在关键问题。These releases are not recommended for production use. 不建议将这些版本用于生产用途。Use the latest available patch release version instead.请改用最新的可用修补程序版本。

Issue问题Affected Versions受影响的版本
SERVER-685116.0.0
WT-104616.0.0 - 6.0.4 (ARM64 or POWER system architectures)

Patch Releases修补程序发布

6.0.8 - Jul 13, 2023

  • SERVER-61127 Multi-writes may exhaust the number of retry attempts in the presence of ongoing chunk migrations在存在正在进行的块迁移的情况下,多次写入可能会耗尽重试次数

  • SERVER-77005 Leave LDAP users logged-in during LDAP downtime在LDAP停机期间让LDAP用户保持登录状态

  • SERVER-78126 For specific kinds of input, mongo::Value() always hashes to the same result on big-endian platforms对于特定类型的输入,mongo::Value()在big-endian平台上总是散列到相同的结果

  • All Jira issues closed in 6.0.8

  • 6.0.8 Changelog

6.0.7 - Jun 28, 2023

  • SERVER-71985 Automatically retry time series insert on DuplicateKey errorDuplicateKey错误时自动重试时间序列插入

  • SERVER-73007 CURL_OPT_SEEKFUNCTION not set for multi-pass authentication未为多次身份验证设置CURL_OPT_SEEKFUNCTION

  • SERVER-74551 WriteConflictException unnecessarily logged as warning during findAndModify after upgrade to mongo 5.0升级到mongo 5.0后,在findAndModify期间不必要地将WriteConflictException记录为警告

  • SERVER-77018 Deadlock between dbStats and 2 index buildsdbStats和2个索引生成之间的死锁

  • WT-10449 Do not save update chain when there are no updates to be written to the history store当没有要写入历史存储的更新时,不保存更新链

  • WT-11031 Fix RTS to skip tables with no time window information in the checkpoint修复RTS跳过检查点中没有时间窗口信息的表的问题

  • All Jira issues closed in 6.0.7所有Jira问题于6.0.7结束

  • 6.0.7 Changelog

6.0.6 - May 12, 2023

  • SERVER-51835 Mongos readPreferenceTags are not working as expectedMongos readPreferenceTags未按预期工作

  • SERVER-67105 $in queries do not use clustered index$in查询不使用聚集索引

  • SERVER-72774 A node in quiesce mode can win election处于静止模式的节点可以赢得选举

  • SERVER-74930 $avg is returning the sum instead of the average in aggregate $group$avg返回的是合计$group中的总和,而不是平均值

  • SERVER-75205 Deadlock between stepdown and restoring locks after yielding when all read tickets exhausted当所有读取的票证都用完时,退位和退位后恢复锁定之间的死锁

  • All Jira issues closed in 6.0.6

  • 6.0.6 Changelog

6.0.5 - Mar 13, 2023

Issues Fixed:

  • SERVER-61909 Hang inserting or deleting document with large number of index entries挂起插入或删除包含大量索引项的文档

  • SERVER-66469 Filtering timeseries with date-field does not include results from before 1970筛选具有日期字段的时间序列不包括1970年以前的结果

  • SERVER-68122 Investigate replicating the collection WiredTiger config string during initial sync调查在初始同步期间复制集合WiredTiger配置字符串

  • SERVER-70395 Slot-Based Engine too aggressively uses disk for $group and is slow基于插槽的引擎过于激进地使用$group的磁盘,并且速度缓慢

  • SERVER-73232 Change the default log-verbosity for _killOperations更改_killOperations的默认日志详细信息

  • All JIRA issues closed in 6.0.5

  • 6.0.5 Changelog

6.0.4 - Jan 26, 2023

Issues Fixed:

  • SERVER-72416 The find and findAndModify projection code does not honor the collection level collationfindfindAndModify投影代码不支持集合级别的排序规则

  • SERVER-71759 dataSize command doesn't yield命令不让步

  • SERVER-70237 Chunks merge commit must not create a BSON object too large区块合并提交不能创建过大的BSON对象

  • SERVER-72222 mapReduce with single reduce optimization fails when merging results in sharded cluster当合并结果在分片集群中时,单个reduce优化失败

  • WT-9268 Delay deletion of the history store record to reconciliation将历史存储记录的删除延迟到对账

  • All JIRA issues closed in 6.0.4

  • 6.0.4 Changelog

6.0.3 - Nov 21, 2022

Issues fixed:

  • SERVER-66289 $out incorrectly throws BSONObj size error on v5.0.8$out在v5.0.8上错误地抛出BSONObj大小错误

  • SERVER-68139 Resharding command fails if the projection sort is bigger than 100MB如果投影排序大于100MB,则重定向命令失败

  • SERVER-68371 Enabling CSFLE in your MongoClient causes Atlas Search to fail在MongoClient中启用CSFLE会导致Atlas Search失败

  • SERVER-68115 Bug fix for "elemMatchRootLength > 0" invariant trigger修复了“elemMatchRootLength>0”不变触发器的错误

  • SERVER-68394 Ensure we do not yield strong locks upon startup recovery when _id index is missing_id索引丢失时,确保在启动恢复时不会产生强锁

  • All JIRA issues closed in 6.0.3

  • 6.0.3 Changelog

6.0.2 - Sep 28, 2022

Issues fixed:

  • SERVER-68925 Reintroduce check table logging settings at startup在启动时重新引入检查表日志记录设置 (revert SERVER-43664)

  • SERVER-68628 Retrying a failed resharding operation after a primary failover can lead to server crash or lost writes在主故障转移后重试失败的重新处理操作可能会导致服务器崩溃或写入丢失

  • SERVER-63852 getThreadName() should not crashgetThreadName()不应崩溃

  • SERVER-65317 mongod removes connection from connection pool after running simple $search querymongod在运行简单的$search查询后从连接池中删除连接

  • SERVER-63843 Don't allow recursive doLog in synchronous signal handlers不允许在同步信号处理程序中使用递归doLog

  • WT-9870 Fix updating pinned timestamp whenever oldest timestamp is updated during recovery修复在恢复期间每当更新最旧的时间戳时更新固定的时间戳的问题

  • All JIRA issues closed in 6.0.2

  • 6.0.2 Changelog

6.0.1 - Aug 19, 2022

Issues fixed:

  • SERVER-68511 MovePrimary update of config.databases entry must use dotted fields notationconfig.databases项的MovePrimary更新必须使用点域表示法

  • SERVER-68062 Multi-stage aggregations that use $geoNear may violate constraints使用$geoNear的多阶段聚合可能违反约束

  • SERVER-66072 $match sampling and $group aggregation strange behavior$match采样和$group聚合的奇怪行为

  • SERVER-68130 AutoSplitVector could generate response bigger than BSONObjMaxUserSizeAutoSplitVector可能生成大于BSONObjMaxUserSize的响应

  • SERVER-68209 Remove uassert that prevents config.image_collection entry from being invalidated删除防止config.image_collection项无效的uassert

  • All JIRA issues closed in 6.0.1

  • 6.0.1 Changelog

6.0.0 - Jul 19, 2022

The rest of this page describes changes and new features introduced in MongoDB 6.0.本页的其余部分介绍了MongoDB 6.0中引入的更改和新功能。

Aggregation聚合

New Aggregation Stages新建聚合阶段

MongoDB 6.0 introduces the following aggregation stages:MongoDB 6.0引入了以下聚合阶段:

Stage阶段Description描述
$densifyCreates new documents in a sequence of documents where values in a specified field are missing.在缺少指定字段中的值的文档序列中创建新文档。
$documentsReturns literal documents from input expressions.从输入表达式返回文字文档。
$fillPopulates null and missing field values within documents.填充文档中的null字段值和缺少的字段值。
$shardedDataDistribution
New in version 6.0.36.0.3版新增: Provides size and data distribution information on sharded collections.:提供有关分片集合的大小和数据分布信息。

New Aggregation Operators新聚合运算符

MongoDB 6.0 introduces the following aggregation operators:MongoDB 6.0引入了以下聚合运算符:

Operator运算符Description描述
$bottomReturns the bottom element within a group according to the specified sort order.根据指定的排序顺序返回组中的底部元素。
$bottomNReturns an aggregation of the bottom n elements within a group, according to the specified sort order.根据指定的排序顺序,返回组中最后n个元素的聚合。
$firstNReturns an aggregation of the first n elements within a group. 返回一个组中前n个元素的聚合。Distinct from the $firstN array operator.$firstN数组运算符不同。
$firstN (array operator)Returns a specified number of elements from the beginning of an array. 从数组的开头返回指定数量的元素。Distinct from the $firstN accumulator.$firstN累加器不同。
$lastNReturns an aggregation of the last n elements within a group. 返回一个组中最后n个元素的聚合。Distinct from the $lastN array operator.$lastN数组运算符不同。
$lastN (array operator)Returns a specified number of elements from the end of an array. 从数组末尾返回指定数量的元素。Distinct from the $lastN accumulator.$lastN累加器不同。
$linearFillFills null and missing fields in a window using linear interpolation based on surrounding field values.使用基于周围字段值的线性插值填充窗口中的null字段和缺失字段。
$locfLast observation carried forward. 最后一次观察继续进行。Sets values for null and missing fields in a window to the last non-null value for the field.窗口null和缺失字段的值设置为该字段的最后一个非null值。
$maxNReturns an aggregation of the n maximum valued elements within a group. Distinct from the $maxN array operator.返回一个组中n个最大值元素的聚合。与$maxN数组运算符不同。
$maxN (array operator)Returns the n largest values in an array. Distinct from the $maxN accumulator.返回数组中最大的n个值。与$maxN累加器不同。
$minNReturns an aggregation of the n minimum valued elements within a group. 返回一个组中n个最小值元素的聚合。Distinct from the $minN array operator.$minN数组运算符不同。
$minN (array operator)Returns the n smallest values in an array. 返回数组中的n个最小值。Distinct from the $minN accumulator.$minN累加器不同。
$sortArraySorts an array based on its elements.根据数组的元素对数组进行排序。
$topReturns the top element within a group according to the specified sort order. 根据指定的排序顺序返回组中的顶部元素。Distinct from the command top.与命令top不同。
$topNReturns an aggregation of the top n elements within a group, according to the specified sort order.根据指定的排序顺序,返回组中前n个元素的聚合。
$tsIncrementReturns the incrementing ordinal from a timestamp as a long.long形式返回时间戳中的递增序号。
$tsSecondReturns the seconds from a timestamp as a long.时间戳中的秒作为long返回。

$lookup and $graphLookup with Sharded Collections带有分片集合的$lookup$graphLookup

Starting in MongoDB 5.1, the $lookup and $graphLookup aggregation stages support sharded collections in the from parameter.从MongoDB 5.1开始,$lookup$graphLookup聚合阶段支持from参数中的分片集合。

In previous versions of MongoDB, $lookup and $graphLookup only allowed for unsharded from collections.在MongoDB的早期版本中,$lookup$graphLookup只允许从集合取消排序。

Change Streams更改流

Optimized Change Streams优化的变更流

Starting in MongoDB 5.1, change streams are optimized, providing more efficient resource utilization and faster execution of some aggregation pipeline stages.从MongoDB 5.1开始,更改流得到了优化,提供了更高效的资源利用率和更快的一些聚合管道阶段的执行。

wallTime Change Stream Output Field更改流输出字段

Starting in MongoDB 6.0, the change stream output has a new wallTime field that contains the server date and time of the database operation.从MongoDB 6.0开始,变更流输出有一个新的wallTime字段,其中包含数据库操作的服务器日期和时间。

Change Streams with Document Pre- and Post-Images使用文档前后图像更改流

Starting in MongoDB 6.0, you can use change streams to output the version of a document before and after changes (the document pre- and post-images). 从MongoDB 6.0开始,您可以使用更改流来输出更改前后的文档版本(文档前和后图像)。For examples, see Change Streams with Document Pre- and Post-Images.例如,请参阅使用文档前图像和后图像更改流

Change Stream Expanded Events更改流扩展事件

Starting in MongoDB 6.0, change streams can show additional change events for DDL operations, like creating indexes and dropping collections.从MongoDB 6.0开始,更改流可以显示DDL操作的其他更改事件,如创建索引和删除集合。

For more information, see Expanded Events.有关详细信息,请参阅扩展的事件

Cluster Administration群集管理

Cluster Server Parameters群集服务器参数

Starting in MongoDB 6.0, you can use MongoDB Cluster Parameters to modify and retrieve configuration options for all nodes in a replica set or sharded cluster. 从MongoDB 6.0开始,您可以使用MongoDB Cluster Parameters来修改和检索副本集或分片集群中所有节点的配置选项。You can use setClusterParameter to modify cluster-wide options and getClusterParameter to retrieve the value of a cluster parameter.可以使用setClusterParameter修改集群范围的选项,使用getClusterParameter检索集群参数的值。

Connection Pool Parameters连接池参数

Starting in MongoDB 6.0, you can use ShardingTaskExecutorPoolMinSizeForConfigServers and ShardingTaskExecutorPoolMaxSizeForConfigServers to set the minimum and maximum sharding TaskExecutor connection pool size for configuration servers.从MongoDB 6.0开始,您可以使用ShardingTaskExecutorPoolMinSizeForConfigServersShardingTaskExecutorPoolMaxSizeForConfigServers来设置配置服务器的最小和最大分片TaskExecutior连接池大小。

changeStreamOptions Cluster Parameter群集参数

Starting in MongoDB 6.0, you can use changeStreamOptions to control the retention policy of change stream pre- and post-images.从MongoDB 6.0开始,您可以使用changeStreamOptions来控制更改流前映像和后映像的保留策略。

internalSessionsReapThreshold Parameter参数

Starting in MongoDB 6.0, you can use the new internalSessionsReapThreshold parameter to set the session limit for internal session metadata deletion.从MongoDB 6.0开始,您可以使用新的internalSessionsReapThreshold参数来设置内部会话元数据删除的会话限制。

Multiple Arbiters Unsupported不支持多个仲裁器

Starting in MongoDB 5.3, support for multiple arbiters in a replica set is disabled by default. 从MongoDB 5.3开始,默认情况下会禁用对副本集中多个仲裁器的支持。To enable support for multiple arbiters, start each node with the allowMultipleArbiters parameter.要启用对多个仲裁器的支持,请使用allowMultipleArbiters参数启动每个节点。

Clustered Collections群集集合

Starting in MongoDB 5.3, you can create a collection with a clustered index. 从MongoDB 5.3开始,您可以创建一个具有聚集索引的集合。Collections created with a clustered index are called clustered collections.使用聚集索引创建的集合称为聚集集合。

To learn about the benefits compared to a normal collection, see Clustered Collections.要了解与普通集合相比的优势,请参阅群集集合

Indexes索引

Starting in MongoDB 5.1, you can use the collMod database command to add the expireAfterSeconds option to an existing single-field non-TTL index.从MongoDB 5.1开始,您可以使用collMod数据库命令将expireAfterSeconds选项添加到现有的单字段非TTL索引中。

Starting in MongoDB 6.0, you can use the prepareUnique and unique options for the collMod command to convert an existing standard index to a unique index.从MongoDB 6.0开始,您可以使用prepareUniquecollMod命令的unique选项将现有的标准索引转换为唯一索引。

Partial Indexes部分索引

Starting in MongoDB 6.0, you can use the operators $in and $or to create partial indexes. 从MongoDB 6.0开始,您可以使用运算符$in$or来创建部分索引。The partialFilterExpression maximum depth is also expanded from 2 to 4. partialFilterExpression的最大深度也从2扩展到4。You can now use the operators $and and $or at non-top-levels.您现在可以在非顶层使用运算符$and$or

Installation安装

SELinux PoliciesSELinux策略

Starting in MongoDB 5.1, there is a new SE Linux Policy for:从MongoDB 5.1开始,有一个新的SE Linux策略用于:

  • MongoDB Enterprise ServerMongoDB企业服务器

  • MongoDB Community Edition ServerMongoDB社区版服务器

running on Red Hat Linux. The SELinux policy is for use with default installations using rpm installer packages.在Red Hat Linux上运行。SELinux策略用于使用rpm安装程序包的默认安装。

Replica Sets复制集

Multiple Arbiters Unsupported不支持多个仲裁器

Starting in MongoDB 5.3, support for multiple arbiters in a replica set is disabled by default. 从MongoDB 5.3开始,默认情况下会禁用对副本集中多个仲裁器的支持。To enable support for multiple arbiters, start each node with the allowMultipleArbiters parameter.要启用对多个仲裁器的支持,请使用allowMultipleArbiters参数启动每个节点。

initialSyncMethod Parameter

Starting in MongoDB 5.2, the initialSyncMethod determines whether initial sync is a logical initial sync or a file copy based initial sync.从MongoDB 5.2开始,initialSyncMethod确定初始同步逻辑初始同步还是基于文件副本的初始同步。

initialSyncMethod is only available in MongoDB Enterprise Server.仅在MongoDB Enterprise Server中可用。

Specify Secondary Oplog Batch Delay指定辅助操作日志批处理延迟

Starting in MongoDB 6.0, you can use the oplogBatchDelayMillis server parameter to specify a delay for writes of oplog batches on secondaries. 从MongoDB 6.0开始,您可以使用oplogBatchDelayMillis服务器参数来指定在辅助设备上写入oplog批的延迟。Adding a short oplog batch delay can reduce IOPS on secondaries, but adds latency for writes with write concern "majority".添加较短的oplog批处理延迟可以降低辅助设备的IOPS,但会增加"majority"写入问题的写入延迟。

For more information, see oplogBatchDelayMillis.有关更多信息,请参阅oplogBatchDelayMillis

Security安全

Audit Log Encryption审核日志加密

Starting in MongoDB 6.0 Enterprise, you can encrypt the MongoDB audit log.从MongoDB 6.0 Enterprise开始,您可以对MongoDB审计日志进行加密。

To configure the audit log, see Audit Log.要配置审核日志,请参阅审核日志

Sharding分片

Default Chunk Size Increased from 64 MB to 128 MB默认区块大小从64 MB增加到128 MB

Starting in MongoDB 5.2, the default chunk size is 128 megabytes. 从MongoDB 5.2开始,默认的区块大小是128兆字节。In earlier versions of MongoDB, the default chunk size is 64 megabytes.在早期版本的MongoDB中,默认块大小为64兆字节。

enableSharding No Longer Required不再需要

Starting in MongoDB 6.0, the enableSharding command is no longer required to shard a collection.从MongoDB 6.0开始,不再需要enableSharding命令来分片集合。

Monitor Defragmentation Status监视分片整理状态

Starting in MongoDB 5.3, the balancerCollectionStatus command returns detailed information when run on a namespace going through chunk defragmentation. 从MongoDB 5.3开始,balancerCollectionStatus命令在进行区块分片整理的命名空间上运行时返回详细信息。The output includes the current phase of the defragmentation and how many chunks are left to process.输出包括分片整理的当前阶段以及还有多少块需要处理。

To see example output, see Ongoing Defragmentation Process.要查看示例输出,请参阅正在进行的分片整理过程

Slot-Based Query Execution Engine基于插槽的查询执行引擎

Starting in MongoDB 5.1, MongoDB uses a new query execution engine for eligible queries, called the slot-based query execution engine. 从MongoDB 5.1开始,MongoDB为符合条件的查询使用了一个新的查询执行引擎,称为基于槽的查询执行发动机。If the slot-based query execution engine is used, new fields are included in the query explain plan output.如果使用基于槽的查询执行引擎,则新字段将包含在查询解释计划输出中。

  • The new query execution engine is used if possible.如果可能的话,将使用新的查询执行引擎。

  • If the new query execution engine is used, new fields are included in the query explain plan output.如果使用新的查询执行引擎,则新字段将包含在查询解释计划输出中

Slot-Based Query Execution Engine Can Execute $group and $lookup Stages基于插槽的查询执行引擎可以执行$group$lookup阶段

Starting in version 6.0, MongoDB uses the slot-based query execution engine to execute eligible $group and $lookup stages when certain conditions are met.从6.0版本开始,MongoDB使用基于槽的查询执行引擎,在满足某些条件时执行符合条件的$group$lookup阶段。

For more information, see Slot-Based Query Execution Engine Pipeline Optimizations.有关更多信息,请参阅基于槽的查询执行引擎管道优化

Set Slot-Based Query Execution Engine Plan Cache Size设置基于插槽的查询执行引擎计划缓存大小

You can set the size of the plan cache for the new query engine with the planCacheSize parameter.您可以使用planCacheSize参数为新查询引擎设置计划缓存的大小。

Increasing the plan cache size adds more cached query shapes for the query planner. 增加计划缓存大小会为查询计划器添加更多缓存的查询形状。This can improve query performance, but increases memory usage.这可以提高查询性能,但会增加内存使用率。

Stable API

The following sections describe additions to the Stable API introduced in MongoDB 6.0.以下部分描述了对MongoDB 6.0中引入的Stable API的添加。

To see the full list of database commands available in the Stable API, see Stable API Changelog.要查看Stable API中可用的数据库命令的完整列表,请参阅Stable API Changelog

Database Commands数据库命令

Starting in MongoDB 6.0, the following database commands are supported in the Stable API:从MongoDB 6.0开始,Stable API支持以下数据库命令:

Command命令Description描述Stable API VersionAPI稳定版本
countCounts the number of documents in a collection or a view. 统计集合或视图中的文档数。(Also available in the Stable API for 5.0-series deployments starting in MongoDB 5.0.9.)(也可在Stable API中获得,用于从MongoDB 5.0.9开始的5.0系列部署。)V1

Aggregation Stages and Operators聚合阶段和运算符

Starting in MongoDB 6.0, the following aggregation stages and operators are supported in the Stable API:从MongoDB 6.0开始,Stable API支持以下聚合阶段和运算符:

Stage or Operator阶段或运算符Description描述Stable API Version
$bottomReturns the bottom element within a group, according to the specified sort order.根据指定的排序顺序,返回组中的底部元素。V1
$bottomNReturns an aggregation of the bottom n elements within a group, according to the specified sort order.根据指定的排序顺序,返回组中最后n个元素的聚合。V1
$dateAddIncrements a Date() object by a specified number of time units.Date()对象增加指定数量的时间单位。V1
$dateDiffReturns the difference between two dates.返回两个日期之间的差值。V1
$dateSubtractDecrements a Date() object by a specified number of time units.Date()对象递减指定数量的时间单位。V1
$dateTruncTruncates a date.截断日期。V1
$densifyCreates new documents in a sequence of documents where certain values in a field are missing.在字段中缺少某些值的文档序列中创建新文档。V1
$firstN (aggregation accumulator)(聚合累加器)Returns an aggregation of the first n elements within a group.返回一个组中前n个元素的聚合。V1
$firstN (array operator)(数组运算符)Returns a specified number of elements from the beginning of an array.从数组的开头返回指定数量的元素。V1
$getFieldReturns the value of a specified field from a document.返回文档中指定字段的值。V1
$lastN (aggregation accumulator)(聚合累加器)Returns an aggregation of the last n elements within a group.返回一个组中最后n个元素的聚合。V1
$lastN (array operator)(数组运算符)Returns a specified number of elements from the end of an array.从数组末尾返回指定数量的元素。V1
$locfLast observation carried forward. 最后一次观察继续进行。Sets values for null and missing fields in a window to the last non-null value for the field.窗口null和缺失字段的值设置为该字段的最后一个非null值。 V1
$maxN (aggregation accumulator)(聚合累加器)Returns an aggregation of the maximum value n elements within a group.返回一个组中最大值n个元素的聚合。V1
$maxN (array operator)(数组运算符)Returns the n largest values in an array.返回数组中最大的n个值。V1
$minN (aggregation accumulator)(聚合累加器)Returns an aggregation of the minimum value n elements within a group.返回一个组中最小值n个元素的聚合。V1
$minN (array operator)(数组运算符)Returns the n smallest values in an array.返回数组中的n个最小值。V1
$setFieldAdds, updates, or removes a specified field in a document.添加、更新或删除文档中的指定字段。V1
$setWindowFieldsPerforms operations on a specified span of documents in a collection, known as a window, and returns the results based on the chosen window operator.对集合(称为窗口)中指定的文档范围执行操作,并根据所选窗口运算符返回结果。V1
$sortArraySorts an array based on its elements.根据数组的元素对数组进行排序。V1
$topReturns the top element within a group according to the specified sort order.根据指定的排序顺序返回组中的顶部元素。V1
$topNReturns an aggregation of the top n elements within a group, according to the specified sort order.根据指定的排序顺序,返回组中前n个元素的聚合。V1
$tsIncrementReturns the incrementing ordinal from a timestamp as a long.long形式返回时间戳中的递增序号。 V1
$tsSecondReturns the seconds from a timestamp as a long.时间戳中的秒以long的形式返回。 V1

Window Operators窗口运算符

Starting in MongoDB 6.0, the following window operators are supported in the Stable API:从MongoDB 6.0开始,Stable API支持以下窗口运算符:

Window Operator窗口运算符Description描述Stable API VersionAPI稳定版本
$addToSetReturns an array of all unique values that results from applying an expression to each document.返回一个数组,该数组包含将表达式应用于每个文档所产生的所有唯一值。V1
$avgReturns the average for the specified expression. 返回指定表达式的平均值。Ignores non-numeric values.忽略非数值。V1
$countReturns the number of documents in the group or window.返回组或窗口中的文档数。V1
$covariancePopReturns the population covariance of two numeric expressions.返回两个数值表达式的总体协方差。V1
$covarianceSampReturns the sample covariance of two numeric expressions.返回两个数值表达式的样本协方差。V1
$denseRankReturns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition. 返回文档相对于$setWindowFields阶段分区中其他文档的位置(称为秩)。There are no gaps in the ranks. Ties receive the same rank.队伍中没有差距。领带的级别相同。V1
$derivativeReturns the average rate of change within the specified window.返回指定窗口内的平均变化率。V1
$documentNumberReturns the position of a document (known as the document number) in the $setWindowFields stage partition. 返回文档在$setWindowFields阶段分区中的位置(称为文档编号)。Ties result in different adjacent document numbers.平局导致相邻文件编号不同。V1
$expMovingAvgReturns the exponential moving average for the numeric expression.返回数值表达式的指数移动平均值。V1
$firstReturns the value that results from applying an expression to the first document in a group or window.返回将表达式应用于组或窗口中的第一个文档所产生的值。V1
$integralReturns the approximation of the area under a curve.返回曲线下面积的近似值。V1
$lastReturns the value that results from applying an expression to the last document in a group or window.返回将表达式应用于组或窗口中的最后一个文档所产生的值。V1
$locfLast observation carried forward. 最后一次观察继续进行。Sets values for null and missing fields in a window to the last non-null value for the field.窗口null和缺失字段的值设置为该字段的最后一个非null值。 V1
$maxReturns the maximum value that results from applying an expression to each document.返回将表达式应用于每个文档所产生的最大值。V1
$minReturns the minimum value that results from applying an expression to each document.返回将表达式应用于每个文档所产生的最小值。V1
$pushReturns an array of values that result from applying an expression to each document.返回将表达式应用于每个文档所产生的值的数组。V1
$rankReturns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition.返回文档相对于$setWindowFields阶段分区中其他文档的位置(称为秩)。V1
$shiftReturns the value from an expression applied to a document in a specified position relative to the current document in the $setWindowFields stage partition.返回应用于文档的表达式中的值,该文档位于$setWindowFields阶段分区中相对于当前文档的指定位置。V1
$stdDevPopReturns the population standard deviation that results from applying a numeric expression to each document.返回对每个文档应用数值表达式所产生的总体标准偏差。V1
$stdDevSampReturns the sample standard deviation that results from applying a numeric expression to each document.返回对每个文档应用数值表达式所产生的标准偏差示例。V1
$sumReturns the sum that results from applying a numeric expression to each document.返回将数值表达式应用于每个文档所产生的总和。V1

Time Series Collections时间序列集合

The following sections describe improvements and new features for time series collections.以下部分介绍时间序列集合的改进和新功能。

Sharded Time Series Collections分片时间序列集合

MongoDB 5.1 provides support for sharded time series collections.MongoDB 5.1提供了对分片时间序列集合的支持。

See:参阅

Sharded Time Series Granularity分片时间序列粒度

Starting in MongoDB 6.0, you can modify the granularity of sharded time series collections.从MongoDB 6.0开始,您可以修改分片时间序列集合的粒度

Updates and Deletes更新和删除

Starting in MongoDB 5.1, time series collections support update and delete operations with limitations.从MongoDB 5.1开始,时间序列集合支持有限制的更新和删除操作

Time Series Column Compression时间序列列压缩

Starting in MongoDB 5.2, time series collections use column compression. 从MongoDB 5.2开始,时间序列集合使用列压缩Column compression adds a number of innovations that work together to significantly improve practical compression, reduce your data's overall storage on disk, and improve read performance.列压缩增加了许多创新,这些创新共同作用,显著提高了实际压缩效果,减少了数据在磁盘上的总体存储,并提高了读取性能。

Starting in MongoDB 6.0, arrays are also compressed as part of the time series column compression.从MongoDB 6.0开始,数组也作为时间序列列压缩的一部分进行压缩。

Support for $geoNear支持$geoNear

Starting in MongoDB 5.3, you can use the $geoNear pipeline operator on any field in a time series collection.从MongoDB 5.3开始,您可以在时间序列集合中的任何字段上使用$geoNear管道运算符。

Additional Secondary Index Types其他二级索引类型

You can add additional secondary index types to time series collections, including 2dsphere and 2d indexes.可以向时间序列集合添加其他辅助索引类型,包括2dsphere2d索引。

For all additional indexes and other improvements, see Time Series Secondary Indexes in MongoDB 6.0 and Later.有关所有其他索引和其他改进,请参阅MongoDB 6.0及更高版本中的时序二级索引

Sort Operations Use Secondary Indexes排序操作使用辅助索引

Sort operations on time series collections can use indexes to improve performance. 时间序列集合上的排序操作可以使用索引来提高性能。For more information and an example, see Use Secondary Indexes to Improve Sort Performance.有关详细信息和示例,请参阅使用辅助索引提高排序性能

General Improvements一般改进

OpenSSL3 FIPS SupportOpenSSL3 FIPS支持

Starting in MongoDB 6.0.7, FIPS mode supports OpenSSL3 for the following operating systems:从MongoDB 6.0.7开始,FIPS模式支持以下操作系统的OpenSSL3

  • Ubuntu 22.04

  • RHEL 9

  • Amazon Linux 2023

Capped Collections Improvements上限集合改进

Starting in MongoDB 6.0, you can change a capped collection's maximum size, either in bytes or in number of documents, using the collMod command. 从MongoDB 6.0开始,您可以使用collMod命令更改封顶集合的最大大小,以字节或文档数为单位。See Resize a Capped Collection for more details.有关详细信息,请参阅调整封顶集合的大小

numOrphanDocs Field Added to collStats Command添加到collStats命令的字段

Starting in MongoDB 6.0, the collStats output includes the collStats.numOrphanDocs field that shows the number of orphaned documents in the collection.从MongoDB 6.0开始,collStats输出包括collStats.numOrphanDocs字段,该字段显示集合中孤立文档的数量。

Exclude Embedded Fields in serverStatus Output排除serverStatus输出中的嵌入字段

Starting in MongoDB 6.0 (and 5.0.9, 4.4.15), you can exclude embedded fields from the serverStatus output.从MongoDB 6.0(和5.0.9、4.4.15)开始,您可以从serverStatus输出中排除嵌入字段。

Connections连接

Starting in MongoDB 6.0, the Mongo() connection object has the following new methods:从MongoDB 6.0开始,Mongo()连接对象有以下新方法:

Support for Diagnostic Backtrace Generation in arm64支持arm64中的诊断回溯生成

Starting in MongoDB 6.0 (and 5.0.10, 4.4.15), diagnostic backtrace generation in arm64 is supported.从MongoDB 6.0(和5.0.10.4.4.15)开始,支持arm64中的诊断回溯生成

Configure Refresh Interval for Cached LDAP User Information配置缓存LDAP用户信息的刷新间隔

Starting in MongoDB 5.2, you can use the following new server parameters to configure the refresh interval for cached LDAP user information:从MongoDB 5.2开始,您可以使用以下新的服务器参数来配置缓存LDAP用户信息的刷新间隔:

Starting in MongoDB 5.2, the update interval for cached user information retrieved from an LDAP server depends on ldapShouldRefreshUserCacheEntries:从MongoDB 5.2开始,从LDAP服务器检索的缓存用户信息的更新间隔取决于ldapShouldRefreshUserCacheEntries

Changes Affecting Compatibility影响兼容性的更改

Some changes can affect compatibility and may require user actions. 某些更改可能会影响兼容性,并且可能需要用户操作。For a detailed list of compatibility changes, see Compatibility Changes in MongoDB 6.0.有关兼容性更改的详细列表,请参阅MongoDB 6.0中的兼容性更改

Upgrade Procedures升级过程

Important

Feature Compatibility Version功能兼容性版本

To upgrade to MongoDB 6.0 from a 5.0 deployment, the 5.0 deployment must have featureCompatibilityVersion set to 5.0. 要从5.0部署升级到MongoDB 6.0,5.0部署必须将featureCompatibilityVersion设置为5.0To check the version:要检查版本:

db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )

To upgrade to MongoDB 6.0, refer to the upgrade instructions specific to your MongoDB deployment:要升级到MongoDB 6.0,请参阅针对您的MongoDB部署的升级说明:

If you need guidance on upgrading to 6.0, MongoDB professional services offer major version upgrade support to help ensure a smooth transition without interruption to your MongoDB application. 如果您需要升级到6.0的指导,MongoDB专业服务提供主要版本升级支持,以帮助确保在不中断MongoDB应用程序的情况下顺利过渡。To learn more, see MongoDB Consulting.要了解更多信息,请参阅MongoDB咨询

Downgrade Consideration降级考虑

MongoDB only supports single-version downgrades. You cannot downgrade to a release that is multiple versions behind your current release.MongoDB只支持单版本降级。您不能降级到比当前版本落后多个版本的版本。

For example, you may downgrade a 6.0-series to a 5.0-series deployment. However, further downgrading that 5.0-series deployment to a 4.4-series deployment is not supported.例如,您可以将6.0系列部署降级为5.0系列部署。但是,不支持将5.0系列部署进一步降级为4.4系列部署。

Download下载

To download MongoDB 6.0, go to the MongoDB Download Center.要下载MongoDB 6.0,请访问MongoDB下载中心

Known Issues已知问题

This section describes known issues in MongoDB 6.0 and their resolution status.本节介绍MongoDB 6.0中的已知问题及其解决状态。

In VersionIssueStatus
6.0.0SERVER-68062: Multi-stage aggregations that use $geoNear may violate constraints.:使用$geoNear的多阶段聚合可能违反约束。Resolved in 6.0.1.

Report an Issue报告问题

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票证的说明。