对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

使用迁移验证器进行验证

重要

迁移验证程序支持MongoDB 4.2 及更高版本的迁移验证。在早期版本中,它可能无法正常运行。

迁移验证程序连接到源集群和目标集群,并执行一系列验证检查,比较文档、视图和索引,以确认同步成功。

与其他验证方法不同,迁移验证程序可以与mongosync同时运行,在同步时检查目标集群上的文档。 这可以减少在将应用程序负载从源集群转移到目标集群之前验证同步是否成功所需的时间。

注意

Migration Verifier 不支持DDL 操作。 使用 Migration Verifier 验证数据时,请勿在源集群上运行任何 DDL 操作。

有关安装说明和使用限制,请参阅 GitHub。

1

使用 mongosync 同步源集群和目标集群。有关更多信息,请参阅 Mongosync 快速入门。

2

必须等到mongosync到达变更事件应用程序 (CEA) 阶段,然后才能开始使用迁移验证程序进行验证检查。

要检查mongosync是否已达到 CEA 阶段,请发送/progress命令并检查progress.info字段是否返回change event application

curl localhost:27182/api/v1/progress -XGET
{
"progress":
{
"state":"RUNNING",
"canCommit":true,
"canWrite":false,
"info":"change event application",
"lagTimeSeconds":0,
"collectionCopy":
{
"estimatedTotalBytes":694,
"estimatedCopiedBytes":694
},
"directionMapping":
{
"Source":"cluster0: localhost:27017",
"Destination":"cluster1: localhost:27018"
}
}
}
3

启动migration-verifier进程:

migration-verifier --verifyAll \
--srcURI example.net:27020 \
--destURI example.net:27021 \
--metaURI example.net:27017
4

要启动验证检查,请使用 cURL 将check命令发送到 Migration Verifier:

curl -H "Content-Type: application/json" \
-X POST -d '{}' http://127.0.0.1:27020/api/v1/check
5

当同步完成且mongosync已达到COMMITTED状态时,使用 cURL 将writesOff命令发送到 Migration Verifier:

curl -H "Content-Type: application/json" \
-X POST -d '{}' http://127.0.0.1:27020/api/v1/writesOff
6

要查看结果,请使用 cURL 将progress命令发送到 Migration Verifier。

curl -H "Content-Type: application/json" \
-X GET http://127.0.0.1:27020/api/v1/progress
{
"progress": {
"phase": "idle",
"error": null,
"verificationStatus": {
"totalTasks": 1,
"addedTasks": 0,
"processingTasks": 0,
"failedTasks": 0,
"completedTasks": 0,
"metadataMismatchTasks": 0,
"recheckTasks": 0
}
}
}

phase字段为idle时,验证检查已完成。 如果failedTasks字段返回 0,则同步成功。

给本页内容打分