警告
mongosync 不检查是否符合记录的限制条件。请确保您的应用程序不受这些限制的影响。在存在这些限制之一的情况下运行 mongosync,可能会导致对目标集群出现未定义的行为。
您必须在整个迁移期间遵守这些限制,包括迁移暂停或停止时(如果要恢复迁移)。
一般限制
注意
有关MongoDB 服务器兼容性的信息,请参阅MongoDB Server版本兼容性。
mongosync不支持在迁移期间更改主要版本或次要版本的就地服务器版本升级。mongosync允许补丁版本升级。要学习;了解更多信息,请参阅服务器升级说明。目标集群必须为空。
mongosync不验证集群或环境是否已正确配置。当
mongosync运行时,其他客户端不得写入目标集群。如果要启动提交进程,并且在使用
enableUserWriteBlocking"sourceAndDestination"start端点时未将 设立为 ,则必须在启动提交进程之前阻止写入源集群。不会复制 system.* 集合。
不支持字段名以美元符号 (
$) 为前缀的文档。请参阅带句点和美元符号的字段名。不支持无服务器集群。
不支持 MongoDB 共享层级。
不支持“可查询加密”。
您无法同步已在相同字段定义唯一索引和非唯一索引的集合。
在尝试使用
M10+Atlas 集群运行mongosync之前,请禁用 Require Indexes for All Queries 选项。mongosync不会同步用户或角色。mongosyncdoes not replicateapplyOpsoperations made on the source cluster during sync to the destination cluster.mongosyncmust read from the source cluster using theprimaryread preference.mongosync不支持当前正在升级 MongoDB 版本的源集群或目标集群。mongosync不支持同步Atlas Search 索引。mongosync仅支持使用WiredTiger存储引擎的集群。您无法将集合与任何具有空时间戳的文档同步,例如 6.0 之前的
Timestamp(0,0)源集群。mongosync不支持具有重复字段名称的文档。 有关详细信息,请参阅MongoDB不支持重复的字段名称。
MongoDB Community Edition
MongoDB不会使用社区版本测试 Mongosync,并且在大多数情况下, MongoDB不支持使用社区部署的 Mongosync。如果您想将 Mongosync 与MongoDB Community Edition一起使用,联系MongoDB销售代表,讨论要求和个性化选项。
不支持的集合类型
不支持时间序列集合。
不支持设置了 expireAfterSeconds 的集群化集合。
分片集群
mongosync不支持从分片集群同步到副本集。mongosync不支持同步到具有一个或多个仲裁节点的分分片集群拓扑结构。mongosyncdoesn't support sync to or from global clusters.从副本集同步到分片集群这一操作具有以下限制:
mongosync允许用户重命名同步期间sharding.shardingEntries选项包含的集合,但有一些限制。 有关详细信息,请参阅在同步期间重命名。如果使用
sharding.createSupportingIndexes选项,则在同步期间会在目标集群上自动创建索引。 此后无法在源集群上创建这些索引。如果要手动创建索引以支持分分片键,则必须在
mongosync启动之前或迁移完成且mongosync停止之后创建索引。
在集合中,
_id字段必须在集群的所有分片中都是唯一的。请参阅分片集群和唯一索引了解详情。The
movePrimarycommand cannot be used to reassign the primary shard while syncing.没有用于区域配置的复制。
mongosync复制数据,但不继承区域。同步时无法添加或删除分片。
mongosync只同步存在于所有分片上的索引。mongosync只同步所有分片上具有一致索引规范的索引。注意
如要检查索引是否存在不一致,请参阅跨分片查找不一致的索引。
如果源集群或目标集群是分片集群,并且您未运行带命名空间筛选功能的
mongosync,则必须通过运行balancerStop命令并等待15 分钟以使命令完成来禁用源集群的负载均衡器。如果源集群或目标集群是分片集群,并且您正在运行带有命名空间筛选的
mongosync,则可以全局启用源集群的负载均衡器,但必须为命名空间过滤内的所有集合禁用它。请参阅在 Filtered Sync 中禁用集合的负载均衡器。您还可以完全禁用源集群的负载均衡器。You must always disable the balancer on a sharded destination cluster by using
balancerStop.If you have enabled the source cluster's balancer, but disabled it for collections within the namespace filter, do not run
shardCollectionon collections within the namespace filter. If you runshardCollectionon collections within the namespace filter during the migration,mongosyncreturns an error and stops, which requires you to start the migration from scratch.mongosyncdoesn't support running the commandtransitionFromDedicatedConfigServerduring execution.同步时无法完善分片键。
The
reshardCollectionoperations from the source cluster are not supported during sync.mongosync只支持同步具有默认排序规则设置的分片集合。mongosync在某些承载数据的分片上不一致或缺失的索引上会出现错误。
反转
- 如果旧源具有唯一的索引,而且这些索引部分分布在不同的分片上,反转可能会导致失败。在反转之前,请确保所有分片上都存在唯一的索引。
源集群和目标集群必须具有相同数量的分片。当集群具有不同的拓扑结构时,您无法进行反向同步。
源集群和目标集群必须运行相同的MongoDB主要版本。
- In order to reverse direction,
mongosyncrequires that all unique indexes on the source cluster (except for_id) do not have legacy unique index keys.
多个集群
mongosync不支持将多个源集群同步到一个目标集群。一个集群不能同时是一个
mongosync实例中的源集群和另一个mongosync实例中的目标集群。
已筛选同步
可逆同步不支持筛选功能。
启动前,目标集群不能包含用户数据。
目标集群在启动前不能包含
mongosync_reserved_for_internal_use系统数据库。不能修改正在使用的筛选器。如需创建新的筛选器,请参阅:“替换现有筛选器”。
您只能在某些情况下重命名集合。有关更多详情,请参阅:添加和重命名集合。
如果过滤器包含视图但不包含基本集合,则只有视图元数据会同步到目标集群。要包含视图文档,您还必须同步基本集合。
不能在筛选器中指定系统集合或系统数据库。
To use the
$outaggregation stage or themapReducecommand (when set to create or replace a collection) with filtering, you must configure the filter to use the entire database. You cannot limit the filter to collections within the database.有关更多信息,请参阅使用 mapReduce 和 $out 进行筛选。
固定大小集合
从 1.3.0 开始,Mongosync 支持固定大小集合,但有一些限制。
convertToCappedis not supported. If you runconvertToCapped,mongosyncexits with an error.cloneCollectionAsCapped不受支持。
同步期间,源集群上的固定大小集合可正常工作。
同步期间,目标集群上的固定大小集合会出现临时更改:
文档数量没有上限。
最大集合大小为 1PB。
mongosync 在提交期间恢复最大文档数量和最大文档大小的原始值。
系统集合
Mongosync 不会将系统集合复制到目标集群。
If you issue a dropDatabase command on the source cluster, this change is not directly applied on the destination cluster. Instead, Mongosync drops user collections and views in the database on the destination cluster, but it does not drop system collections on that database.
例如,在目标集群上:
The drop operation does not affect a user-created
system.jscollection.If you enable profiling, the
system.profilecollection remains.If you create views on the source cluster and then drop the database, replicating the drop removes the views, but leaves an empty
system.viewscollection.
在这些情况下,复制 dropDatabase 时会删除数据库中所有用户创建的集合,但会将其系统集合留在目标集群上。
MongoDB Atlas内部数据库
mongosync 1.17如果目标集群包含非空__mdb_internal_atlas 数据库, 及更早版本会返回错误。这是MongoDB Atlas使用的内部数据库。您可能会收到一条错误,指出"found existing data on the destination cluster; the destination cluster must be empty; please drop existing data on the destination and start the migration again" 。
为避免迁移失败,升级到 mongosync 1.18 或更高版本,这会自动忽略所有内部数据库。
滚动索引构建
mongosync does not support rolling index builds during migration. To avoid building indexes in a rolling fashion during migration, use one of the following methods to ensure that your destination indexes match your source indexes:
迁移前在源上构建索引。
Build the index on the source during migration with a default index build.
迁移后在目标上构建索引。
嵌入式验证程序
从 1.9 开始,mongosync 可以使用嵌入式验证器来确认集合从源集群成功同步到目标集群。
兼容性
嵌入式验证程序在 mongosync 1.8 及更早版本中不可用。
限制
嵌入式验证程序具有以下限制:
mongosync将验证者状态存储在内存中,这可能会导致大量内存开销。 要运行验证程序,mongosync大约需要 10 GB内存,此外,每 1 万份文档需要额外 500 MB 内存。验证程序无法恢复。 如果用户停止或暂停同步,然后因任何原因再次启动
mongosync,验证进程将从头开始。 这可能会导致验证大大落后于迁移。
不支持的验证检查
验证程序不会检查以下命名空间:
固定大小集合
具有TTL索引的集合,包括在迁移过程中添加或删除的TTL索引
不使用默认的集合
视图
验证程序不会检查以下集合功能:
集合元数据
索引
要验证上述数据和元数据,请为这些集合和集合功能编写额外检查的脚本。 有关详细信息,请参阅验证数据传输。
注意
从版本1.10 开始,验证程序会检查迁移期间. 60之前的源集群上发生的 DDL事件中的数据是否不一致。这是因为.6 0之前的迁移不支持DDL 事件。
要学习;了解详情,请参阅. 60之前的迁移限制。
持久查询设置
mongosync 不会迁移MongoDB 8.0 中引入的持久查询设置 (PQS)。如果源集群使用 PQS,则必须手动迁移。
6.0 之前的迁移
从 1.10 开始,mongosync 支持运行早于 6.0 的MongoDB服务器版本的源集群进行迁移。 有关支持的迁移路径的信息,请参阅MongoDB Server版本兼容性。
以下限制应用于 6.0 迁移:
迁移期间,源集群上不能执行会产生 DDL 事件的写入操作。以下事件不会发生:
collModcreatecreateIndexesdropdropDatabasedropIndexesrefineCollectionShardKeyrenamereshardCollectionshardCollection
This includes operations that may create new collections such as
mapReduce,$out, and$merge. This also includes collections created implicitly from inserts. Only writes that produce CRUD events can occur during the migration.geoHaystack不支持索引。不支持 /reverse 端点。您无法在
reversible/start请求中启用 选项。您无法在
/start请求中将enableUserWriteBlocking选项设立为"sourceAndDestination",因此不支持双重写入阻塞。 支持仅目标写入阻塞。 确保在调用/commit端点后不对源集群进行任何写入。如果一个或多个分片上存在规格不一致或缺失的索引,
mongosync将返回错误。要检查索引是否存在不一致,请参阅查找分片间不一致的索引。The source cluster cannot have orphaned documents. To clean up any orphaned documents, run the
cleanupOrphanedcommand on your source cluster.