ソースクラスターをクエリし、ドキュメント、インデックス、コレクション、メタデータ、ビューを宛先クラスターと比較するためのスクリプトを記述できます。
ドキュメントの比較
ソースクラスターと宛先クラスターのドキュメントを比較することで、同期を確認できます。
この方法でデータ転送を確認する前に、mongosync は COMMITTED 状態である必要があります。
比較インデックス
To verify the transfer of indexes, run db.collection.getIndexes() on the source and destination clusters and compare the results.
メタデータの比較
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" })