On this page本页内容
MongoDB 5.1 is a rapid release and is only supported for MongoDB Atlas. MongoDB 5.1是一个快速版本,只支持MongoDB Atlas。MongoDB 5.1 is not supported for use on-premises. MongoDB 5.1不支持在本地使用。For more information, see MongoDB Versioning.有关更多信息,请参阅MongoDB版本控制。
The following 5.1 changes can affect compatibility with older versions of MongoDB.以下5.1更改可能会影响与旧版本MongoDB的兼容性。
Starting in MongoDB 5.1, these operators are removed:从MongoDB 5.1开始,删除以下运算符:
$comment | cursor.comment() |
$explain | cursor.explain() |
$hint | cursor.hint() |
$max | cursor.max() |
$maxTimeMS | cursor.maxTimeMS() |
$min | cursor.min() |
$orderby | cursor.sort() |
$query | See Cursor Methods |
$returnKey | cursor.returnKey() |
$showDiskLoc | cursor.showRecordId() |
db.getLastError() | See Legacy Opcodes Removed |
db.getLastErrorObj() | See Legacy Opcodes Removed |
getLastError | See Legacy Opcodes Removed |
MongoDB 5.1 removes the following server parameters:MongoDB 5.1删除了以下服务器参数:
--tlsFIPSMode |
|
MongoDB 5.1 removes the following parameters from the MongoDB 5.1从mongo shell中删除以下参数:mongo
shell:
--useLegacyWriteOps | |
--writeMode | |
--readMode | |
--rpcProtocols |
$setWindowFields
Starting in MongoDB 5.1 (and 5.0.4), the 从MongoDB 5.1(和5.0.4)开始,$setWindowFields
stage cannot be used within transactions or with "snapshot"
read concern.$setWindowFields
阶段不能在事务中使用,也不能与"snapshot"
读取关注点配合使用。
Starting in MongoDB 5.1, when starting, restarting or adding a shard server with 从MongoDB 5.1开始,在使用sh.addShard()
the Cluster Wide Write Concern (CWWC) must be set.sh.addShard()
启动、重新启动或添加分片服务器时,必须设置集群范围的写入关注点(CWWC)。
If the 如果未设置CWWC
is not set and the shard is configured such that the default write concern is { w : 1 }
the shard server will fail to start or be added and returns an error.CWWC
,并且已将分片配置为默认写入关注点为{w:1}
,则分片服务器将无法启动或添加,并返回错误。
See default write concern calculations for details on how the default write concern is calculated.有关如何计算默认写入关注点的详细信息,请参阅默认写入关注点计算。
rs.reconfig
Starting in MongoDB 5.1, you must set the Cluster Wide Write Concern (CWWC) prior to issuing any 从MongoDB 5.1开始,必须先设置集群范围的写入关注点(CWWC),然后再进行任何reconfigs
that would otherwise change the default write concern of the new replica set member.reconfigs
,否则会更改新副本集成员的默认写关注点。
Arbiters are not supported with quarterly rapid releases releases. 季度快速发布不支持。If your deployment includes arbiters, only use LTS releases.如果部署中包含仲裁器,则只使用LTS版本。
If you create a sharded time series collection in MongoDB 5.1 or greater, downgrading to a version older than MongoDB 5.0.4 will result in data loss.如果在MongoDB 5.1或更高版本中创建分片时间序列集合,降级到MongoDB 5.0.4之前的版本将导致数据丢失。
Before downgrading to a version older than 5.0.4, drop all sharded time series collections.在降级到早于5.0.4的版本之前,请删除所有分片时间序列集合。
$regex
Starting in MongoDB 5.1, invalid 从MongoDB 5.1开始,无效的$regex options
options are no longer ignored. $regex
选项将不再被忽略。This change makes 此更改使$regex options
more consistent with the use of $regex
in the aggregate
command and projection queries.$regex
选项与在aggregate
命令和投影查询中使用$regex
更加一致。
$regex
Starting in MongoDB 5.1, if a collection has schema validation rules that contain invalid 从MongoDB 5.1开始,如果集合的架构验证规则包含无效的$regex options
the server:$regex
选项,则服务器:
Starting in MongoDB 5.1, instances running in FIPS mode have the SCRAM-SHA-1 authentication mechanism disabled by default. 从MongoDB 5.1开始,在FIPS模式下运行的实例默认禁用了SCRAM-SHA-1身份验证机制。You can enable the SCRAM-SHA-1 authentication mechanism with the setParameter.authenticationMechanisms command.可以使用setParameter.authenticationMechanisms命令启用SCRAM-SHA-1身份验证机制。
This change will not affect drivers which target MongoDB 此更改不会影响以MongoDB setFeatureCompatibilityVersion
4.0+.setFeatureCompatibilityVersion
4.0+为目标的驱动程序。
$mod
Starting in MongoDB 5.1 (and 5.0.4 and 4.4.10), the 从MongoDB 5.1(以及5.0.4和4.4.10)开始,如果$mod
operator returns an error if the divisor
or remainder
values evaluate to certain values. divisor
(除数)或remainder
(余数)值计算为特定值,$mod
运算符将返回一个错误。See $mod behavior.
MongoDB drivers have used OP_MSG instead of OP_QUERY and the other legacy opcodes since MongoDB v3.6.MongoDB驱动程序使用了OP_MSG,而不是OP_QUERY,以及自MongoDB v3.6以来的其他遗留操作码。
This release removes support for the following legacy opcodes:此版本取消了对以下旧操作码的支持:
To avoid disruption due to the removal of these op codes, please upgrade your driver to the latest version.为避免因删除这些操作码而中断,请将驱动程序升级至最新版本。
mongod
will close the connection and will not respond to:将关闭连接,并且不会响应:
mongod
will return an error for:将返回以下内容的错误:
The OP_QUERY RPC protocol may be used with the following commands:OP_QUERY RPC协议可与以下命令一起使用:
_isSelf
authenticate
buildinfo
buildInfo
hello
ismaster
isMaster
saslContinue
saslStart
OP_QUERY will return an error if it is used for a find operation. 如果用于查找操作,将返回错误。All other commands will be rejected if issued as OP_QUERY.如果作为OP_QUERY发出,所有其他命令将被拒绝。
If you attempt to connect to a MongoDB 3.4, or older, 如果您试图使用MongoDB 5.1或更新版本的mongod
instance with a MongoDB 5.1, or newer, mongo
shell, you will receive an error message like the following:mongo
shell连接到MongoDB 3.4或更早版本的mongod
实例,您将收到如下错误消息:
// Reformated for clarity. The message appears on a single line. Connection handshake failed. Is your mongod 3.4 or older? :: caused by :: network error while attempting to run command 'isMaster' on host '127.0.0.1:27017'
Starting in MongoDB 5.1.2 the following platforms are no longer supported.从MongoDB 5.1.2开始,以下平台不再受支持。
Some features in 5.1 require the 5.1 binaries and the featureCompatibilityVersion (fCV) must also be set to 5.1. 5.1中的某些功能需要5.1二进制文件,功能兼容性版本(fCV)也必须设置为5.1。These features include:这些特点包括: