|
| 1 | +.. _c2c-verification: |
| 2 | + |
| 3 | +==================== |
| 4 | +Verify Data Transfer |
| 5 | +==================== |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. facet:: |
| 10 | + :name: genre |
| 11 | + :values: reference |
| 12 | + |
| 13 | +.. contents:: On this page |
| 14 | + :local: |
| 15 | + :backlinks: none |
| 16 | + :depth: 2 |
| 17 | + :class: singlecol |
| 18 | + |
| 19 | +When :program:`mongosync` has fully committed, verify the successful transfer |
| 20 | +of your data before you switch your application to using the destination |
| 21 | +cluster. You can verify your data transfer using document counts, hash |
| 22 | +comparison, document comparison, or the Migration Verifier. |
| 23 | + |
| 24 | +Use Cases |
| 25 | +--------- |
| 26 | + |
| 27 | +You should verify your data after every sync. This is important in |
| 28 | +cases where you plan to move your application load from the source to the |
| 29 | +destination cluster. |
| 30 | + |
| 31 | +Verification methods: |
| 32 | + |
| 33 | +- :ref:`c2c-verify-with-doc-counts` |
| 34 | + |
| 35 | +- :ref:`c2c-verify-with-hash-comp` |
| 36 | + |
| 37 | +- :ref:`c2c-verify-with-doc-comp` |
| 38 | + |
| 39 | +- :ref:`c2c-verify-with-verifier` |
| 40 | + |
| 41 | +The specific method you use to verify your data depends on your application |
| 42 | +workload and the complexity of the data. |
| 43 | + |
| 44 | +.. _c2c-verify-method: |
| 45 | + |
| 46 | +Tasks |
| 47 | +------- |
| 48 | + |
| 49 | +.. _c2c-verify-with-doc-counts: |
| 50 | + |
| 51 | +Document Counts |
| 52 | +~~~~~~~~~~~~~~~ |
| 53 | + |
| 54 | +The most basic method of verification is to compare the number of documents |
| 55 | +in each synced collection on the source cluster to the number on the |
| 56 | +destination cluster. |
| 57 | + |
| 58 | +This method only verifies a successful sync when run against clusters with |
| 59 | +insert-only workloads. |
| 60 | + |
| 61 | +For more information, see :ref:`c2c-verify-doc-counts`. |
| 62 | + |
| 63 | +.. _c2c-verify-with-hash-comp: |
| 64 | + |
| 65 | +Hash Comparison |
| 66 | +~~~~~~~~~~~~~~~ |
| 67 | + |
| 68 | +You can verify sync by comparing MD5 hashes of collections synced from the |
| 69 | +source cluster to the destination cluster. |
| 70 | + |
| 71 | +While hash comparison ensures that the destination cluster has received all |
| 72 | +changes from the source, the :dbcommand:`dbHash` command locks the cluster, |
| 73 | +preventing additional writes until it completes. |
| 74 | + |
| 75 | +.. note:: |
| 76 | + |
| 77 | + Hash comparison is not possible with sharded clusters. It also does not |
| 78 | + work for standalone servers and replica sets that use MongoDB 4.4 or earlier |
| 79 | + releases, since the document field order can vary. |
| 80 | + |
| 81 | +For more information, see :ref:`c2c-verify-hash-comp`. |
| 82 | + |
| 83 | +.. _c2c-verify-with-doc-comp: |
| 84 | + |
| 85 | +Document Comparison |
| 86 | +~~~~~~~~~~~~~~~~~~~ |
| 87 | + |
| 88 | +You can verify sync by comparing documents on the source and destination |
| 89 | +clusters. Write a script that queries collections on the source cluster and |
| 90 | +then checks that the document exists with the same values on the destination |
| 91 | +cluster. |
| 92 | + |
| 93 | +.. _c2c-verify-with-verifier: |
| 94 | + |
| 95 | +Migration Verifier |
| 96 | +~~~~~~~~~~~~~~~~~~ |
| 97 | + |
| 98 | +Migration Verifier connects to the source and destination clusters and performs |
| 99 | +a series of verification checks, comparing documents, views, and indexes to |
| 100 | +confirm the sync was successful. |
| 101 | + |
| 102 | +.. important:: |
| 103 | + |
| 104 | + Migration Verifier is an experimental and unsupported tool. |
| 105 | + |
| 106 | + For installation instructions, see |
| 107 | + `GitHub <https://github.com/mongodb-labs/migration-verifier>`__. |
| 108 | + |
| 109 | +Unlike other verification methods, Migration Verifier can run concurrent |
| 110 | +with ``mongosync``, checking documents on the destination cluster as they |
| 111 | +sync. |
| 112 | + |
| 113 | +For more information, see :ref:`c2c-migration-verifier`. |
| 114 | + |
| 115 | +.. toctree:: |
| 116 | + :hidden: |
| 117 | + |
| 118 | + /reference/verification/count |
| 119 | + /reference/verification/hash |
| 120 | + /reference/verification/verifier |
| 121 | + |
| 122 | +Learn More |
| 123 | +---------- |
| 124 | + |
| 125 | +For more information, see: |
| 126 | + |
| 127 | +- :method:`db.collection.countDocuments` |
| 128 | + |
| 129 | +- :dbcommand:`dbHash` |
| 130 | + |
| 131 | + |
| 132 | + |
0 commit comments