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

使用自定义脚本验证数据

您可以写入脚本来查询源集群,并将文档、索引、集合、元数据和视图与目标集群进行比较。

您可以通过比较源集群和目标集群上的文档来验证同步。

在使用此方法验证数据传输之前,mongosync 必须处于 COMMITTED 状态。

db.collection.getIndexes()要验证索引的传输,请在源集群和目标集群上运行 并比较结果。

To verify the transfer of metadata, run db.getCollectionInfos() on the source and destination clusters and compare the results.

要验证分片键是否传输到同步集合,请对 config.collections集合运行查询,以查找 _id 值为目标集合的命名空间的文档。 比较此文档在源集群和目标集群中的 key 值。

For example, for a collection named pets in the records database, you can verify the shard key using the following query in mongosh:

db.getSiblingDB("config").collections.find({ _id : "records.pets" })